摘要:FindControl in DataList
Method 1.
If you need to get all textbox from all row of datalist,
foreach (DataListItem dli in dataLst.Items)
{
TextBox cb = (TextBox)dli.FindControl("txtName");
}
Method 2.
If you need to get textbox from current row (selected row) of datalist,
protected void dataLst_ItemCommand(object source, DataListCommandEventArgs e)
{
TextBox txtName = (TextBox)e.Item.FindControl("txtName");
}
Do let me know,if you need more details.
資料來源:
http://social.msdn.microsoft.com/Forums/en-US/84165c94-16b1-4092-9b34-6203eba38649/finding-a-control-in-a-datalist?forum=csharplanguage