ASP.Net Button Command Not Firing (C#)

Associate
Joined
25 Feb 2007
Posts
905
Location
Midlands
I have an initial summary GridView which has a datasource created from a SQL database. The rows in this GridView can be clicked which passes parameters to the URL.

As this initiates a page load, I have an if statement to check for a certain querystring and modifying the datasource based on the other parameters passed, so I'm using the same GridView with a sort of 'drilldown' feature.

After the drilldown, I want to add an additional column with a button, which I've managed to do. I need this buttoon to update a field in the database when clicked, so I've set the button.CommandName property to a method which does this.

Everything works fine, except the method doesn't fire when I click the button!

From some research, it seems that as the clicking of the button triggers a postback, the event is caught??

Can anyone help?

Thanks :D
 
To be honest I'm quite new to this(!) A GridView was the only way I could see to display data from a database in tabular form. Can you provide any examples of how I'd use AJAX to do this? I'm only updating one field in my database though - it's more of a 'view only' app and the user never sees the field being updated, is Ajax still the way to go?

Yes I have a button within my GridView, and can you expand on what you mean by validation controls durbs?

Basically what I'm trying to implement is a way for the user to hide a row that they've already 'dealt' with. So the button updates a date field in the database with a 'today + 1' value. The query which populates the GridView then ignores all rows with dates greater than today.

Thanks for the replies guys, much appreciated!
 
OK, I've resolved my issue - like an idiot, I forgot to add the OnRowCommand attrbute to the GridView markup! Always the simplest of things!

I'm still interested in making my application better though, so the above still applies! :D
 
Back
Top Bottom