Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to save, edit, and read data (in code behind) from an unbound Gridview in ASP.NET

Posted on 2010-01-08
2
Medium Priority
?
512 Views
Last Modified: 2012-05-08
Hi experts,

I am having some issues trying to save and edit data from an unbound asp.net gridview.  Is this even possible?
Here's the scenario.  I populate a gridview in VS2008 with a dataset and datatable which I create programmatically
on Page_Load of the main page.  This grid contains a listing of the fieldnames from an xsd fille that changes based
on what report a user selects from a hard-coded folder path.  This grid also contains sorting options for sorting
any of the fields (given a numeric #), whether or not to include a given field on a report, and whether or not sorting
should occur in Ascending or Descending order.  The population of this grid with field names is fine and Edit/Update/Cancel
links are visible.  My problem is in obtaining the values after the user hits update so that I can save it to the in-memory
recordset and then re-bind the grid with the new data.  In this way I can build a dynamic SQL statement to build a
query for a report which will then get rendered via the in memory dataset.  Does anyone have any concrete examples
that actually work or give me some links that will actually help me out?  

I have tried to get the controls data via findcontrols at various levels in the object but I still seem to get nothing
returned.

Bob
0
Comment
Question by:sharizod
2 Comments
 
LVL 10

Accepted Solution

by:
RameshS earned 2000 total points
ID: 26267215
Please try the following link.

Unbound GridView
0
 
LVL 1

Author Comment

by:sharizod
ID: 26280487
Thanks Ramesh!  I tried creating the fields dynamically before and the controls would end up being named random names (ctl09, ctl10 etc..) which wasn't working too well.  The templated fields did the trick, although in the example, in the html, I found that I had to use '<%# Container.DataItem("FieldName") %>' instead of '<%# Bind("FieldName") %>' which was throwing errors at runtime.

Cheers,
Bob
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

571 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