Sqldatasource updating gridview

Funny though, when I run the site after adding that, but without the Bind command, the process runs without errors, but the row doesn't update. I tried this on the Northwind sample database and it definitely works. The reason you are getting this error is that you have Categories in the ID-Name-Category table that do not exist in the seperate Categories table.

This could be due to a completely missing record, or even a slight typo.

I don't know why yet, or how to bind the page..if I remove Data Bind from Page_Load, updating is successful. This means fresh data is retrieved from the database as soon as the page loads. Is Post Back) This way, Data Bind is only called when the page initially loads and leaves your edits alone on postback. Get the data from your database using a sqldatareader and store it in a custom collection by defining your own custom object.

This in turn means any customizations to the data (e.g. To avoid that problem, wrap the call to Data Bind in a check for Posat Back. Hope this helps, Imar --------------------------------------- Imar Spaanjaars Then bind to the collection using the pageload event and when page.ispostback = false.

NET 2.0 Professional section of the Wrox Programmer to Programmer discussions.

I have a select statement set in an Sql Data Source that returns a result table like this: Major Stone ID | Band Style ID | Type ID | Cut ID | Weight | Color | Clarity | Qty | Unit Price | Stone Name | Cut Name Stone Name and Cut Name come from joins with other tables. Updating, the new values collection also does not have the updated values. To simplify the problem, if I set up my Sql Data Source the same way, then drop a datagrid on the form and autogenerate the columns and edit buttons, I still get the problem.

Many people all over the net are having this trouble too, and I've tried a ton of things.

sqldatasource updating gridview-9

It does seem odd because there's no link to the Drop Down Box's value in there.The update procedure for the Sql Data Source updates the following fields: Type ID | Cut ID | Weight | Color | Clarity | Qty | Unit Price These are the only fields available for editing in the Grid View. Parameters, I see that the values have not been updated. After clicking update, the New Values collection of the Grid View Update Event Args does not contain the updated values. In my Page_Load event, I call Data Bind() to bind other bindings on the page.The problem is, that when I press update with a breakpoint on Sql Data Source. This prevents the grid from updating for some reason. Hi there, When you call Data Bind in Page_Load, you tell your controls to data bind. NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004My advice would be to steer clear of the sqldatasource and use a 3-tiered approach to retrieving, displaying and collecting data.A Grid View generally shows and allows the user to update rows in a database.They are easy to set up until the values that you want to update is a foreign key.

Leave a Reply