我在datalist里面嵌套一个datagrid,这个datagrid里面有一个linkbutton,我要用它完成datagrid数据的一个操作!
本人写的代码:(没有效果)
private void FriendGrid_ItemCommand(object source,DataGridCommandEventArgs e)
{
if (e.CommandName=="FriendDelete")
{
int id=(int)(e.CommandArgument);
mySql="Update U_setup Set accept=0 where id="+id;
myConn.Open();
SqlCommand myCmd=new SqlCommand(mySql,myConn);
myCmd.ExecuteNonQuery();
myConn.Close();
BindDataGrid();
}
} private void CircleList_ItemCreate(object sender,DataListItemEventArgs e)
{
((DataGrid)(e.Item.FindControl("FriendGrid"))).ItemCommand+=new DataGridCommandEventHandler(this.FriendGrid_ItemCommand);
}
本人写的代码:(没有效果)
private void FriendGrid_ItemCommand(object source,DataGridCommandEventArgs e)
{
if (e.CommandName=="FriendDelete")
{
int id=(int)(e.CommandArgument);
mySql="Update U_setup Set accept=0 where id="+id;
myConn.Open();
SqlCommand myCmd=new SqlCommand(mySql,myConn);
myCmd.ExecuteNonQuery();
myConn.Close();
BindDataGrid();
}
} private void CircleList_ItemCreate(object sender,DataListItemEventArgs e)
{
((DataGrid)(e.Item.FindControl("FriendGrid"))).ItemCommand+=new DataGridCommandEventHandler(this.FriendGrid_ItemCommand);
}
{
((DataGrid)(e.Item.FindControl("FriendGrid"))).ItemCommand+=new DataGridCommandEventHandler(this.FriendGrid_ItemCommand);
}这句应该放在初始化那里吧,这样都可以?
void CmdUpdate()
{}
然后按钮得ONCLICK="CmdUpdate"不过我在看用用委托为什么有问题