在DataGrid摸板列中有一列编辑列:
aspx代码:<asp:CheckBoxList id="CheckBoxList1" runat="server" Width="200px" RepeatColumns="2">
<asp:ListItem Value="xxxx">xxxx</asp:ListItem>
<asp:ListItem Value="..">..</asp:ListItem>
...
</asp:CheckBoxList>
cs代码:更新函数如下:
public void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{   
string key = DataGrid1.DataKeys[DataGrid1.EditItemIndex].ToString();
string sqlQuery="...";
           
sqlConnection1.Open();

string quanxian;  //记录权限序列
quanxian="";
if (CheckBoxList1.Items[0].Selected)  ////编辑提示此行出问题!!!
{quanxian+="1";}
else
{ quanxian+="0";}
if (CheckBoxList1.Items[1].Selected)
{quanxian+="1";}
else
{quanxian+="0";}
...........编辑后提示“未将对象引用到实例”,看了一些文章还是不太明白,请各位方家指点~~