C sqldatasource onupdating

Rated 4.81/5 based on 558 customer reviews

Edit Looking at your code, I don't think you're ever binding your Grid View, so your Sql Data Source is never trying to select the data from your database.

In your Page_Load method, add the following code: Further edit Try changing "onselected" to "On Selected" on your Sql Data Source and remove the line to bind your event handler in the code behind.

But somewhere i need a TRY CATCH block just in case my connection get's lost. If i get a error i want my lbl Message Text to be "No connection".

Edit My Grid View in my Sorry, but you're going to have to have some code in the code-behind!

When this event exits though, I get the following error: I see that the Updating event on the datasource is being called after the Row Updating event.

I have tried to cancel this event to prevent the multiple update attempts, but then nothing happens and the Grid View stays in edit mode.

Here is my code: SQL DATA SOURCE " and it will work, or I can do this: "UPDATE item SET Stat = '3' WHERE Item ID = @ID" and it will work.

It must be an issue with this command: "reconcile Data Source.

I have a Transactions table which stores individual items that the user selects for purchase (item name, item price, order ID, etc) I have an Orders table which stores values for the Order (account name, order total, etc) Here is my Sql Data Source as defined in the page: " Insert Command="INSERT INTO [tbl Orders] ([Order Date], [Order Total], [Order Account], [Order Cost Centre]) VALUES (@Order Date, @Order Total, @Order Account, @Order Cost Centre); SELECT @Order New ID = SCOPE_IDENTITY()" Select Command="SELECT * FROM [tbl Orders]" Update Command="UPDATE [tbl Orders] SET [Order Date] = @Order Date, [Order Total] = @Order Total, [Order Account] = @Order Account, [Order Cost Centre] = @Order Cost Centre WHERE [Order ID] = @original_Order ID AND [Order Date] = @original_Order Date AND [Order Total] = @original_Order Total AND [Order Account] = @original_Order Account AND [Order Cost Centre] = @original_Order Cost Centre" Old Values Parameter Format String="original_" oninserting="Sql Data Source2_Inserting" oninserted="Sql Data Source2_Inserted" onupdated="Sql Data Source2_Updated" onupdating="Sql Data Source2_Updating" //Update Order Table with Total of Order //Sql Data Source2.

but here on row updating no point of creating Sql Data Source just for updating database.

The command executes successfully and I can pull the data back to confirm that the parameter was set correctly. If I manually define a default value or manually enter a value in the update statement it works fine, but if I try to set it through a command it does not work. To String();" Which I have tested and confirmed it is in fact returning "3".

I'm stumped if that doesn't work as you've basically got the simplest-possible example.

Even further edit Try this instead In the code behind, in the page_init event handler, wire-up the event handler by typing "Grid View1.

Leave a Reply