更新时间:2023-10-06 22:41:58
<asp:TextBox ID="txtValue" runat="server" Text='<%# Bind("Value") %>'></asp:TextBox>
这里 Value
name是 DataSource $ c中的列名 $ c>。
假设您从数据库获取数据并将其绑定到 DataSet
。
所以,这个 Value
列应该出现在 DataSet $ c $里面c>。
Here "Value
" name is the Column Name in the DataSource
.
Suppose, you are getting data from Database and Binding it to a DataSet
.
So, this "Value
" Column should be present inside the DataSet
.
你好,
绑定DataGridView中的单元格
到文本框,我们可以使用TextBox.DataBinding.Add()
方法使用以下代码。这里Text
表示要绑定的控件属性的名称,dt是对象表示数据源,两个
是要绑定到的属性或列表(此处为列名称)。
Hello,
To bind a cell inDataGridView
to a Text Box, we could just use the following codes, usingTextBox.DataBinding.Add()
method. And here "Text
" means the name of control property to bind, dt is the object represents the data source, and "Two
" is the property or list to bind to (column name here).
DataTable dt = new DataTable();
dt.Columns.Add("One");
dt.Columns.Add("Two");
dt.Columns.Add("Three");
dt.Rows.Add(new string[] { "1", "2", "3" });
dt.Rows.Add(new string[] { "4", "5", "6" });
dt.Rows.Add(new string[] { "7", "8", "9" });
dataGridView1.DataSource = dt;
textBox1.DataBindings.Add("Text", dt, "Two");
查看一些演示项目,链接如下所示
GridView控件
带文本框,复选框,单选按钮和DropDown列表的可编辑网格视图大>
See some demo projects, Links are following below
GridView Control
Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List