C#的DataGrid还有这样的问题?????
我用了绑定字段:
<asp:ButtonColumn Text="选择" DataTextField="档案号" HeaderText="档案号" CommandName="Select">
之后在以下事件中读取就得到是空值,但如果不绑定字段,将DataGrid设成“在运行时自动创建列”,再直接绑定DataTable到DataGrid就可以读到数据,为什么?
private void dgCard_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//设置当前记录的索引
string id=e.Item.Cells[0].Text.Trim();
Session["saveid"]=id;
Session["edittype"]=0; //edit data
}