得不到datagrid中一列的数据string s=E.Item.Cells [0].Text .ToString ();
string s=E.Item.Cells [0].Text .ToString ();
s得不到数据,不知道是为什么
public void BindGrid()
{//从文件Web.config中读取连接字符串
string strconn= ConfigurationSettings.AppSettings[ "dsn "];
//连接本地计算机的MMS数据库
SqlConnection cn= new SqlConnection (strconn);
//创建SqlDataAdapter对象,调用存储过程
SqlDataAdapter da=new SqlDataAdapter ( "employlist ",cn);
//创建并填充DataSet
DataSet ds=new DataSet ();
da.Fill (ds);
dgd_employlist.DataSource =ds;
dgd_employlist.DataBind ();
cn.Close ();
}
private void dgd_employlist_DeleteCommand(object sender, DataGridCommandEventArgs E)
{
string conn= ConfigurationSettings.AppSettings[ "dsn "];
//连接本地计算机的MMS数据库
SqlConnection cn2= new SqlConnection (conn);
cn2.Open ();
string empoydelete= "delete from employ where eno=@eno ";
SqlCommand cm=new SqlCommand (empoydelete,cn2);
cm.Parameters .Add ( "@eno ",SqlDbType.VarChar );
//从DateGrid中取得更新内容
//Cells [0]为UID列
string s=E.Item.Cells [0].Text .ToString ();
cm.Parameters [ "@eno "].Value =s;
cm.ExecuteNonQuery ();
cn2.Close();
dgd_employlist.EditItemIndex =-1;
BindGrid();
Label1.Text= "调出人员为\n "+ s;
}
[解决办法]
超级衔接列好象是有这个问题的
那你把这列帮定到隐藏列里,再取隐藏列的值吧