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
ALOK SHARMA
NA
51
12.8k
Updating through gridview doesn't works
Feb 3 2014 5:45 AM
I am trying to update in gridview but it's not getting update
Below is my coding
protected void GridView_Updating(object sender, GridViewUpdateEventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=SONY-VAIO\SQLEXPRESS;Initial Catalog=Employee;Integrated Security=True");
con.Open();
Label lb = (Label)GridView.Rows[e.RowIndex].FindControl("Id");
RadioButtonList rd = (RadioButtonList)GridView.Rows[e.RowIndex].FindControl("rdStatus");
CheckBoxList cb = (CheckBoxList)GridView.Rows[e.RowIndex].FindControl("ChkActive");
TextBox tx1 = (TextBox)GridView.Rows[e.RowIndex].FindControl("txtId");
TextBox tx2 = (TextBox)GridView.Rows[e.RowIndex].FindControl("txtName");
TextBox tx3= (TextBox)GridView.Rows[e.RowIndex].FindControl("txtAddress");
DropDownList ddl = (DropDownList)GridView.Rows[e.RowIndex].FindControl("ddlDepartment");
SqlCommand cmd = new SqlCommand("Update Edittable set Name=@Name , Address=@Address,Status=@Status,Active=@Active,Department=@Department,Salary=@Salary WHERE Id=@Id", con);
cmd.Parameters.AddWithValue("@Id", txtId.Text.ToString());
cmd.Parameters.AddWithValue("@Name", txtName.Text.ToString());
cmd.Parameters.AddWithValue("@Address", txtAddress.Text.ToString());
cmd.Parameters.AddWithValue("@Department", ddlDepartment.SelectedValue.ToString());
cmd.Parameters.AddWithValue("@Salary", txtSalary.Text.ToString());
cmd.Parameters.AddWithValue("@Active", ChkActive.SelectedValue.ToString());
cmd.Parameters.AddWithValue("@Status", rdStatus.SelectedValue.ToString());
cmd.ExecuteNonQuery();
GridView.EditIndex = -1;
FillGridView();
}
Reply
Answers (
18
)
Regarding Partial Views
unable to insert checkbox value and radiobutton value