积极答复者
datalist中textbox的OnTextChanged中如何取DataKeyField中的值

问题
答案
-
你好,试试下面的方法
this.DataList1.DataKeys[(((sender as TextBox).Parent) as DataListItem).ItemIndex]
Microsoft Online Community Support- 已标记为答案 KeFang Chen 2010年3月18日 7:15
全部回复
-
你好!通过 Control 的 NamingContainer 获取控件在 GridView 中所在的行。
protected void txtName_TextChanged(object sender, EventArgs e) { GridViewRow gridViewRow = (GridViewRow)((TextBox)sender).NamingContainer; object key = this.GridView1.DataKeys[gridViewRow.RowIndex].Value; Response.Write(key.ToString()); }
知识改变命运,奋斗成就人生! -
你好,试试下面的方法
this.DataList1.DataKeys[(((sender as TextBox).Parent) as DataListItem).ItemIndex]
Microsoft Online Community Support- 已标记为答案 KeFang Chen 2010年3月18日 7:15