I am trying to generate a gridview dynamically through codebehind. So I am making all the columns through code using BoundField and other controls.
Now I am trying to to put a edit button in the gridview sand prog开发者_StackOverflow中文版ram that(I made a RowEditing handler). Right now all my code is in the page_load but when I hit the edit button in the gridview I get 2 gridviews back on post back.
So I tried to put a isPostback if statement to stop this but then I just get a error back saying it can't find the handler.
So I am not sure what to do.
Thanks
Depends how you created the control, what version of Visual Studio, and how nested it is.
For example I currently just went backwards a bit in technology. I'm using 17 gridviews on a page that are all sql server 2000 driven from code behind and i have a dropdown in the grid for even row as well. vs 2005 2.0 is what i am using.
I'm using a Master Page (which typically will not be a problem from gridviews, but will need ResolveUrl for jquery references)
Getting to your question, I seem to have that problem with .net asking for a handler when i would tend to copy and paste from .aspx html source. I have MultiView/View/FormView etc... so I tried CTYPE etc..., but upon re-doing the edit with being on the aspx page design view, then use properties and the events. Or if it is a link or button on the page then click on it in design view and it should take you there and NOT have a problem with the Handles.
Some of my code for Edit Button etc.....
THEN in your properties -> Events, look for "RowEditing" and write in a name then put breakpoints in where it is called and you are there really for edit mode... I only use 2 other events "RowCancelingEdit" and then "RowUpdating" Thus I click Edit (which everything is readonly), and a postback occurs (eventually i was to be doing grids again with ajax and not have postbacks) then my fields are in edit mode and dropdown shows list from database as well .... I can update or cancel.... either way it ends in back to readonly state with Edit button visible.
Please post some code if you are still having issues with it.
精彩评论