Solved

Asp.net, vb - dynamic table

Posted on 2010-09-02
5
348 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now