Solved

Asp.net, vb - dynamic table

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

705 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

16 Experts available now in Live!

Get 1:1 Help Now