private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
switch(((LinkButton)e.CommandSource).CommandName)
{ case "update":
Response.Redirect("ElecWeaponUpdate.aspx?id="+ DataGrid1.SelectedItem.Cells[4].Text);
break; // Add other cases here, if there are multiple ButtonColumns in
// the DataGrid control. default:
// Do nothing.
break; }
}
这段代码给报错是: 未将对象引用设置到对象的实例
请问怎么修改!!
{
switch(((LinkButton)e.CommandSource).CommandName)
{ case "update":
Response.Redirect("ElecWeaponUpdate.aspx?id="+ DataGrid1.SelectedItem.Cells[4].Text);
break; // Add other cases here, if there are multiple ButtonColumns in
// the DataGrid control. default:
// Do nothing.
break; }
}
这段代码给报错是: 未将对象引用设置到对象的实例
请问怎么修改!!
(((LinkButton)e.CommandSource).CommandName)这个地方是否有值?
DataGrid1.SelectedItem.Cells[4].Text(上面如果正确)是否有值?
报错是: 未将对象引用设置到对象的实例