我已经使用
创建了一个gridview并在其中填充了数据 Dim Arrays As String() = Functions.runAnalyticsReportSample(100216)
Dim table As New DataTable()
Dim colID As DataColumn = table.Columns.Add("ID", GetType(String))
Dim colReferenceNumber As DataColumn = table.Columns.Add("Case", GetType(String))
Dim colPart_Name As DataColumn = table.Columns.Add("Name", GetType(String))
For Each line In Arrays
Dim split As String() = line.Split(","c)
Dim row As DataRow = table.NewRow()
row.SetField(colID, Integer.Parse(split(0)))
row.SetField(colReferenceNumber, split(1))
row.SetField(colPart_Name, split(2))
table.Rows.Add(row)
Next
GridView1.DataSource = table
GridView1.DataBind()
现在我想在Gridview中将Part Name作为文本框字段,因此可以更新我已添加模板字段的数据
<asp:GridView ID="GridView1" runat="server" onselectedindexchanged="GridView1_SelectedIndexChanged" class="table table-striped table-bordered table-hover">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Eval("Name")%>' ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我在textbox字段中获得了价值,如何删除其他列,因为我到了Name列
答案 0 :(得分:2)
检查GridView.AutoGenerateColumns属性。如果设置为“true”,它将自动生成结果数据集的所有列。将AutoGenerateColumns设置为false并添加要手动显示的列。