TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ankita Singh
NA
159
19k
update data in gridview control
Mar 22 2018 3:56 AM
hello friends...
this is my code
protected void update(object sender, GridViewUpdateEventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnectionstr"].ConnectionString);
int id = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
string qry = "update City_tbl set State=@State,City=@City where id=" + id + "";
SqlCommand cmd = new SqlCommand(qry, con);
cmd.Parameters.AddWithValue("@State", SqlDbType.NVarChar).Value = state.Text.Trim();
cmd.Parameters.AddWithValue("@City", SqlDbType.NVarChar).Value = TextBox1.Text.Trim();
// cmd.Parameters.AddWithValue("@State", ((DropDownList)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).SelectedItem.Value.ToString());
//cmd.Parameters.AddWithValue("@City", ((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text.ToString());
con.Open();
cmd.ExecuteNonQuery();
con.Close();
GridView1.EditIndex = -1;
BindData();
}
here state is dropdown control and city is textbox control.. when click update button then value got null value .. plase someone help me.. thankyou
Reply
Answers (
5
)
Error in File C:\WINDOWS\TEMP\HeadWise {00423A6D-7910-4204-9
ReportHandler' could be found