且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将TableData绑定到Asp.Net + C#中的TextBox控件中

更新时间:2022-05-02 02:33:18

使用数据控件.将文本框放置在itemtemplate中并绑定控件.这样的东西(根据图片)

Use a data control. Place the textboxes in the itemtemplate and bind the control. Something like this(according to image)

<asp:Repeater ID="rptDocuments" runat="server" >      
      <ItemTemplate>
                  <tr>
                    <td >
                       
                     <asp:TextBox ID="TextBox1" runat="server" Width="10" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem,"ColumnName") %>'></asp:TextBox>
                    </td>
                  </tr>
      </ItemTemplate>    
      </asp:Repeater>


像这样尝试
try like this
DataSet ds = new DataSet();
da.Fill(ds, "employee");
// Bind to FirstName column of the Employees table 
textBox1.DataBindings.Add("text", ds, "employee.firstname");