• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

Asp.net, vb - dynamic table

On my asp.net page, after querying a database, I need to create a dynamic table with TextBoxes to display the results.

The user will be able to edit the values in the TextBoxes and click a button to write these values to a different database table.

I need some examples (vb please).
0
Rick
Asked:
Rick
  • 3
  • 2
1 Solution
 
RickAuthor Commented:
I got my own solution by binding a gridview to a datatable, then using a for loop to read the changes and write the values to the db.
0
 
RickAuthor Commented:
found my own solution
0
 
InteqamCommented:
But i think mine is valid!!!
0
 
InteqamCommented:
you said that  you did:
1- binding a gridview to a datatable,
2-  using a for loop to read the changes and write the values to the db.


This was exactly what my solution did:

10 Binding :
<Columns>
<asp:BoundColumn DataField="EmployeeId" HeaderText="EmployeeId"></asp:BoundColumn>
  <asp:TemplateColumn HeaderText="LastName">
     <ItemTemplate>
        <asp:TextBox EnableViewState=True id=LastName runat="server"
         Text='<%# DataBinder.Eval(Container, "DataItem.LastName") %>'>
         </asp:TextBox>
     </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="FirstName">
      <ItemTemplate>
        <asp:TextBox ID="FirstName" enableViewState = true runat="server"
            Text='<%# DataBinder.Eval(Container, "DataItem.FirstName") %>'>
        </asp:TextBox>
     </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="HomePhone">
      <ItemTemplate>
        <asp:TextBox ID="HomePhone" enableViewState = true runat="server"
            Text='<%# DataBinder.Eval(Container, "DataItem.HomePhone") %>'>
        </asp:TextBox>
     </ItemTemplate>
     </asp:TemplateColumn>
</Columns>

Then looping

 foreach(DataGridItem itm in DataGrid1.Items )
    {
        foreach (DatasetColumnNameToGridColumnIndex ColName in System.Enum.GetValues(typeof(DatasetColumnNameToGridColumnIndex)))
        {          
            UpdateDataTableFromGrid(dt, ColName.ToString(), itm, (int)ColName);                  
        }
    }
    DataGrid1.DataSource=dt;
    Session["dt"]=dt;
    DataGrid1.DataBind();
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now