Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Asp.net, vb - dynamic table

Posted on 2010-09-02
5
350 Views
Last Modified: 2012-05-10
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
Comment
Question by:Rick
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:Inteqam
ID: 33592783
0
 
LVL 13

Accepted Solution

by:
Rick earned 0 total points
ID: 33621545
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
 
LVL 13

Author Closing Comment

by:Rick
ID: 33621554
found my own solution
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33622716
But i think mine is valid!!!
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33623074
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question