Click here to Skip to main content
15,909,835 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
MY ROW UPDATING CODE IS BELOW


protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox txtname = (TextBox)GridView1.Rows[e.RowIndex].FindControl("textbox7");
TextBox txtcity = (TextBox)GridView1.Rows[e.RowIndex].FindControl("textbox8");
TextBox txtstate = (TextBox)GridView1.Rows[e.RowIndex].FindControl("textbox9");
TextBox txtbirthdate = (TextBox)GridView1.Rows[e.RowIndex].FindControl("textbox10");
TextBox txteducation = (TextBox)GridView1.Rows[e.RowIndex].FindControl("textbox11");
TextBox txtaddress = (TextBox)GridView1.Rows[e.RowIndex].FindControl("textbox12");
TextBox txthobby = (TextBox)GridView1.Rows[e.RowIndex].FindControl("textbox13");
RadioButtonList rgender = (RadioButtonList)GridView1.Rows[e.RowIndex].FindControl("radiobuttonlist2");
prop.name = txtname.Text;
prop.city = txtcity.Text;
prop.state = txtstate.Text;
prop.birthdate = txtbirthdate.Text;
prop.education = txteducation.Text;
prop.address = txtaddress.Text;
prop.gender = rgender.Text;
prop.hobby = txthobby.Text;
data.update(prop);
GridView1.EditIndex = -1;
fillgrid();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
fillgrid();
}
}


update stored procedure

SQL
ALTER PROCEDURE dbo.updatedata

	
	@id int,
	 @name varchar(50),
	@city varchar(50),
	@state varchar(50),
	@birthdate varchar(50),
	@education varchar(50),
	@address varchar(50),
	@gender varchar(50),
	@hobby varchar(50)


AS
	update info set name=@name,city=@city,state=@state,birthdate=@birthdate,education=@education,address=@address,gender=@gender,hobby=@hobby where id=@id
	RETURN


[edit]Code blocks added - OriginalGriff[/edit]
Posted
Updated 13-Nov-13 16:02pm
v5
Comments
joshrduncan2012 13-Nov-13 14:00pm    
1) Please format your code with the pre tags.

2) What is your question?
OriginalGriff 13-Nov-13 14:06pm    
What happens when you try?
What does it do that you didn't expect, or not do that you did?
Was there any message, or error?
What values did you try?

Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
Patel Shweta 13-Nov-13 14:19pm    
i dont get any error but its not upadating data in my table
i dont why whats the mistake in my code. please give ans.
ZurdoDev 13-Nov-13 22:18pm    
Your C# code does not go with your SQl code. Where is the code that calls SQL?
Patel Shweta 13-Nov-13 22:29pm    
public void update(propertylayer p)
{
cmd = new SqlCommand("updatedata", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@id", p.id);
cmd.Parameters.AddWithValue("@name", p.name);
cmd.Parameters.AddWithValue("@city", p.city);
cmd.Parameters.AddWithValue("@state", p.state);
cmd.Parameters.AddWithValue("@birthdate", p.birthdate);
cmd.Parameters.AddWithValue("@education", p.education);
cmd.Parameters.AddWithValue("@address", p.address);
cmd.Parameters.AddWithValue("@gender", p.gender);
cmd.Parameters.AddWithValue("@hobby", p.hobby);
con.Open();
cmd.ExecuteNonQuery();
con.Close();


}

1 solution

You need to pass something unique in sp. where you want to update particular row
like 'ID'
 
Share this answer
 

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