Gridview rowupdating code
Gridview rowupdating code - Online sex
In the template field I will Place a label or some controls, So that it’s very easy to access those controls in the code behind by using Find Control method. Item Template is the content to display for the items in the Template Field.
If he clicks edit (or) in the edit mode he can be able to see the Textbox.You can see the C# code below will give the row number whatever you are editing by New Edit Index property.So Grid View will put the appropriate row into the Edit Mode by assigning row number to its Edit Index property. You can follow any responses to this entry through the RSS 2.0 feed.Then again we have to call that Bind Grid Data () method to bind data for the textboxes. You can leave a response, or trackback from your own site.The above piece of code will also do the same as label in Item Template and Textbox in the Edit Item Template.By default all the boundfields will be trasferred as Textboxes in Edit Mode.
To avoid this we need to keep the property Read Only as false, Then in the edit mode nothing will happenes. The reason I use Template Field instead of Bound Field is that, it is very easy to grab those controls in the codebehind if we user labels or textboxes.
In case of the bound field’s we need to check what column it is and need to use index of that cloumn, which is little hard and even in future if we change the column order If you see the Last Template Field part in the above code, I am using the link buttons for edit, update, delete and cancel.
May be you may think why am I using link buttons as we are provided with some command field buttons by Grid View.
Secondly if you want to include a custom field (some button or link) in the same column it’s not possible.
If we use proper command names for the buttons like “EDIT”, “DELETE”, “UPDATE”, “CANCEL” these will also trigger the appropriate Grid View Events.
Ok let’s move on to Code behind what we have to do when user clicks Edit, Delete, Update and Cancel When we click on Edit the On Row Editing event will be fired.