My update button not working?

Posted by Raghuldrag under C# on 6/5/2013 | Points: 10 | Views : 683 | Status : [Member] | Replies : 1
Hai Friends,
txtname=name
dropdown=class

button=ADD
button= modify


gridview

name class details
ram 2 edit


if i choose edit from gridview ll appear above textboxes when i try to give modify its not working?

paste code here any body tell me what's wrong with that?


protected void Button1_Click(object sender, EventArgs e)
{

string strcon = ConfigurationManager.ConnectionStrings["AccessConnectionString"].ConnectionString;

SqlConnection conn = new SqlConnection(strcon);
conn.Open();
string ht = "update grts set name=@name,class=@class where id=@id";
SqlCommand cmd = new SqlCommand(ht, conn);
// cmd.CommandType = CommandType.StoredProcedure;
//cmd.Parameters.Add("@status", SqlDbType.VarChar).Value = "update";
cmd.Parameters.AddWithValue("@name", txtname.Text);
cmd.Parameters.AddWithValue("@class", DDL_Class.Text);
cmd.Parameters.AddWithValue("@id", Txtid.Text);
cmd.ExecuteNonQuery();
conn.Close();
binddata();
txtname.Text = "";
DDL_Class.Text = "0";

}




Responses

Posted by: NARAAYANAN on: 6/21/2013 [Member] Starter | Points: 25

Up
0
Down
Hi ,
Did you get any error when you do this ? Please mentioned it.

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Raghuldrag, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response