下面的代码怎么简化?
TextBox1.Text = ds.Tables[temp1].Rows[0][0].ToString();
TextBox2.Text = ds.Tables[temp1].Rows[0][1].ToString();
TextBox3.Text = ds.Tables[temp1].Rows[0][2].ToString();
TextBox4.Text = ds.Tables[temp1].Rows[0][3].ToString();
TextBox5.Text = ds.Tables[temp1].Rows[0][4].ToString();
TextBox6.Text = ds.Tables[temp1].Rows[0][5].ToString();
TextBox7.Text = ds.Tables[temp1].Rows[0][6].ToString();
TextBox8.Text = ds.Tables[temp1].Rows[0][7].ToString();
TextBox9.Text = ds.Tables[temp1].Rows[0][8].ToString();
TextBox10.Text = ds.Tables[temp1].Rows[0][9].ToString();
TextBox11.Text = ds.Tables[temp1].Rows[0][10].ToString();
TextBox12.Text = ds.Tables[temp1].Rows[0][11].ToString();
TextBox13.Text = ds.Tables[temp1].Rows[0][12].ToString();
TextBox14.Text = ds.Tables[temp1].Rows[0][13].ToString();
TextBox15.Text = ds.Tables[temp1].Rows[0][14].ToString();
TextBox16.Text = ds.Tables[temp1].Rows[0][15].ToString();
TextBox17.Text = ds.Tables[temp1].Rows[0][16].ToString();
TextBox18.Text = ds.Tables[temp1].Rows[0][17].ToString();
TextBox1.Text = ds.Tables[temp1].Rows[0][0].ToString();
TextBox2.Text = ds.Tables[temp1].Rows[0][1].ToString();
TextBox3.Text = ds.Tables[temp1].Rows[0][2].ToString();
TextBox4.Text = ds.Tables[temp1].Rows[0][3].ToString();
TextBox5.Text = ds.Tables[temp1].Rows[0][4].ToString();
TextBox6.Text = ds.Tables[temp1].Rows[0][5].ToString();
TextBox7.Text = ds.Tables[temp1].Rows[0][6].ToString();
TextBox8.Text = ds.Tables[temp1].Rows[0][7].ToString();
TextBox9.Text = ds.Tables[temp1].Rows[0][8].ToString();
TextBox10.Text = ds.Tables[temp1].Rows[0][9].ToString();
TextBox11.Text = ds.Tables[temp1].Rows[0][10].ToString();
TextBox12.Text = ds.Tables[temp1].Rows[0][11].ToString();
TextBox13.Text = ds.Tables[temp1].Rows[0][12].ToString();
TextBox14.Text = ds.Tables[temp1].Rows[0][13].ToString();
TextBox15.Text = ds.Tables[temp1].Rows[0][14].ToString();
TextBox16.Text = ds.Tables[temp1].Rows[0][15].ToString();
TextBox17.Text = ds.Tables[temp1].Rows[0][16].ToString();
TextBox18.Text = ds.Tables[temp1].Rows[0][17].ToString();
解决方案 »
- 初学者的问题
- .net批量轉資料
- ASP.NET弹出画面的问题
- 要实现查询几个表时的一个问题,老是想不通
- 为何将程序上传到租用的服务器上有时运行会报错!!!!急急
- 验证控件的问题,系统提示少文件?
- 利用ASPX发EMAIL碰到的一点问题
- 高手请进,不好意思就30分了,请大家帮忙
- asp.net(vb)与asp.net(c#)能集成在同一个解决方案吗?
- 【Response.Redirect()醒目】try{...}catch{...}里是不是不能同时有Redirect()方法?【Response.Redirect()醒目】
- DataGrid生成动态列,在对数据修改后,按button保存,为什么从DataGrid.Items取得count为0?
- 郁闷死了,找好久资料都找不到,现在就问一个简单明了的问题,只用回答是与不是就可以了,
只要有规律
for(int i=0;i<17;i++)
{
(TextBox)(TextBox+(i+1).ToString()).Text=ds.Tables[temp1].Rows[0][i].ToString();
}
弄也repeater把数据绑定上去
搞了17 8个textbox服务器控件太多了
<HeaderTemplate>
<table width="100%" border="0" cellpadding="2" align="center">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>企业ID:<%# DataBinder.Eval(Container.DataItem,"id")%></td>
</tr>
<tr>
<td>企业名称:<%# DataBinder.Eval(Container.DataItem,"name")%></td>
</tr>
<tr>
<td>注册时间:<%# DataBinder.Eval(Container.DataItem,"regDate")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
后台绑定repeater就可以了