首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

小弟我数据库里有10条数据如何动态绑定到十个文本框里啊

2012-03-23 
我数据库里有10条数据怎么动态绑定到十个文本框里啊?文本框为INPUTTYPETEXTBOXRUNATSERVER怎么依次绑定

我数据库里有10条数据怎么动态绑定到十个文本框里啊?
文本框为   INPUT   TYPE=TEXTBOX   RUNAT   =SERVER
怎么依次绑定到十个文本框内
我用DATASET循环得到十行数据,   而不是10个字段值,请大家注意

[解决办法]
html:

<table width= "400 " cellpadding= "2 ">
<tr>
<td>
<asp:TextBox id= "txt_ww_1 " runat= "server "> </asp:TextBox> </td>
<td>
<asp:TextBox id= "txt_ww_2 " runat= "server "> </asp:TextBox> </td>
<td>
<asp:TextBox id= "txt_ww_3 " runat= "server "> </asp:TextBox> </td>
<td>
<asp:TextBox id= "txt_ww_4 " runat= "server "> </asp:TextBox> </td>
<td>
<asp:TextBox id= "txt_ww_5 " runat= "server "> </asp:TextBox> </td>
</tr>
<tr>
<td>
<asp:TextBox id= "txt_ww_6 " runat= "server "> </asp:TextBox> </td>
<td>
<asp:TextBox id= "txt_ww_7 " runat= "server "> </asp:TextBox> </td>
<td>
<asp:TextBox id= "txt_ww_8 " runat= "server "> </asp:TextBox> </td>
<td>
<asp:TextBox id= "txt_ww_9 " runat= "server "> </asp:TextBox> </td>
<td>
<asp:TextBox id= "txt_ww_10 " runat= "server "> </asp:TextBox> </td>
</tr>
</table>


.cs

if(!IsPostBack)
{
string[] strTextBoxString = { "textbox1 "
, "textbox2 "
, "textbox3 "
, "textbox4 "
, "textbox5 "
, "textbox6 "
, "textbox7 "
, "textbox8 "
, "textbox9 "
, "textbox10 "};

int index = 1;

foreach(string str in strTextBoxString)
{
TextBox tb = (TextBox)this.FindControl( "txt_ww_ " + index);
tb.Text = str;

index ++;
}
}

热点排行