Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created one employee table.
I tried to insert data in it. Now I want to update the data in it. For that I used grid view. Now came to know that following key words I have to use.
XML
<asp:GridView ID="EmployeeGridView"   
              runat="server" 
              AutoGenerateColumns="False"
              DataKeyNames="Emp_id"     
              onrowcancelingedit="EmployeeGridView_RowCancelingEdit"
              onrowediting="EmployeeGridView_RowEditing"              
              onrowdeleting="EmployeeGridView_RowDeleting"
              onrowupdating="EmployeeGridView_RowUpdating">

I have used methods for updating, deleting but I don't know where to place those methods. Please tell me where to use it.
As i am new to .net, explain me in a easier way, so that I could be able to understand.
Posted
v2

 
Share this answer
 
v2
Comments
vinod.sambangi 21-Nov-12 3:56am    
Where to place the code of it.This "protected void grdContact_RowUpdating(object sender, GridViewUpdateEventArgs e)
" function where i can get in the page and to place it.Please tell me.
__TR__ 21-Nov-12 5:08am    
The code will be in your code behind (.cs) file.
vinod.sambangi 21-Nov-12 5:18am    
I was getting error in the following code in "e.RowIndex" in the below code
"
protected void EmployeeGridView_RowUpdating(object sender, GridViewEditEventArgs e)

{
int empid =((TextBox)EmployeeGridView.Rows[e.RowIndex].FindControl("txtempexp")).Text;//Get Each Row unique value from DataKeyNames
string name = ((TextBox)EmployeeGridView.Rows[e.RowIndex].FindControl("txtempname")).Text;//get TextBox Value in EditItemTemplet that row is clicked
"
It was saying error as "using System.Web.UI.WebControls.GridViewCancelEditEventArgs
does not contain definition of RowIndex and RowIndex accepting first arguement of
System.Web.UI.WebControls.GridViewCancelEditEventArgs
could be found"
.This is the error.Please tell me
__TR__ 21-Nov-12 5:30am    
For row update event your method should look like
protected void EmployeeGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
And the error you have included looks like its generated for Cancel Edit Event.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900