troubleshooting Question

Editable Gridview to edit underlying DataTable in ASP.NET (C#)

Avatar of toooki
toooki asked on
.NET ProgrammingASP.NET
6 Comments2 Solutions536 ViewsLast Modified:
In my ASP.NET code in C# (VS 2008) I have created a gridView and here is the .aspx code:

        <asp:GridView ID="grid1" runat="server">

In aspx.cs code I have created a DataTable via program code and I could bind to the GridView by this code:

            grid1.DataSource = dsOut;

dsOut above has variable number of columns and unknown column names (names of the columns are determined in the program code).
The content shows in the GridView correctly. How can I make the GridView  editable so that after the Submit button is pressed --

 protected void btn1_Click(object sender, EventArgs e)
        DataTable dt = (DataTable)grid1.DataSource;

The above works. I can get the data in "dt" but all I need it seems to make the GridView editable..

Kaushal Arora
Technical Analyst

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros