62,267
社区成员
发帖
与我相关
我的任务
分享
{
StringBuilder s = new StringBuilder();
s.AppendLine("<table style='width:800px' border=1>");
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox ck = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1");
if (ck.Checked)
{
//GridView1.Columns
s.AppendLine("<tr>");
for (int j = 0; j < GridView1.Columns.Count; j++)
{
s.AppendFormat("<td>{0}</td>", GridView1.Rows[i].Cells[j].Text);
}
s.AppendLine("</tr>");
}
}
s.Append("</table>");
Export("application/ms-excel", "excel.xls", s.ToString());
s.AppendLine("<table style='width:800px' border=1>");
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox ck = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1");
if (ck.Checked)
{
//GridView1.Columns
s.AppendLine(" <tr>");
for (int j = 0; j < GridView1.Columns.Count; j++)
{
s.AppendFormat("<td>{0} </td>", ((Label)GridView1.Rows[i].Cells[j].FindControl("Label")).Text);
// 提示出错:System.NullReferenceException: 未将对象引用设置到对象的实例。
}
s.AppendLine(" </tr>");
}
}
s.Append("</table>");
Export("application/ms-excel", "excel.xls", s.ToString());
for(int i=0;i<=GridView1.Rows.Count-1;i++)
{
CheckBox cbox=(CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
Lebel.Test=cbox.Text;
}
<span id="ctl00_mainholder_GridView1_ctl03_Label1">2</span>
</td><td style="width:150px;">
<a href='complaindisplay.aspx?feedID=3859e483-27c8-496d-9212-096a0e329ad5'>
<span id="ctl00_mainholder_GridView1_ctl03_Label2">我对“游泳衣约定”的看法</span></a>
</td><td style="width:60px;">
<span id="ctl00_mainholder_GridView1_ctl03_Label3">POI</span>
</td><td style="width:60px;">
<span id="ctl00_mainholder_GridView1_ctl03_Label4">我对“游泳衣约定”的看法</span>
</td><td style="width:60px;">
<span id="ctl00_mainholder_GridView1_ctl03_Label5"> </span>
</td><td style="width:60px;">
<span id="ctl00_mainholder_GridView1_ctl03_Label6">客户公司</span>
</td><td style="width:60px;">
<span id="ctl00_mainholder_GridView1_ctl03_Label7"> </span>