{
CheckBox c1;// = new CheckBox();
for(int i =0;i<dg1.Items.Count;i++)
{
c1 =(CheckBox)dg1.Items[i].FindControl("CheckBox1");
if(c1 !=null && c1.Checked )
{
Label1.Text = Label1.Text +dg1.Items[i].Cells[1].Text;
Label2.Text = Label2.Text +dg1.Items[i].Cells[2].Text;
}
}
注意 c1 != null 這條判斷,如果沒有加這條判斷,則會發生 Null 的異常錯誤