怎样取得DataList中定义的TextBox的文本值?(大家帮哈忙)
比如如下代码,我要怎么样在后台中遍历TEXTBOX的值,我弄了好久都没弄好
大家帮忙整哈看看,感激不尽
<asp:DataList ID= "DataList1 " runat= "server " DataKeyField= "ID " Height= "553px " Width= "667px ">
<ItemTemplate>
<asp:TextBox ID= "Tanswer " runat= "server " Text= ' <%# Eval( "answercontent ") %> ' > </asp:TextBox>
</ItemTemplate>
</asp:DataList>
------解决方案--------------------private void btnSubmit_Click(object sender, System.EventArgs e)
{
foreach(DataListItem d in DataList1.Items)
{
TextBox t = (TextBox)dgi.FindControl( "Tanswer ");
if(t != null)
{
// t.Text得到文本框的值
//DataList1.DataKeys[d.ItemIndex].ToString() 得到当前行主键值,记得最好提前设置好DataList的DataKeyField
}
}
}