I am trying to update records in the gridview through "Save" button, and save button is outside of GridView. The problem is with the paging.
When i update records using save button, it is updating records, but paging is not working properly. The next page is showing blank.
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack){
con.Open();
SqlCommand cmd = new SqlCommand("select * from MyTable", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
RadGrid1.DataSource = ds;
RadGrid1.DataBind();
}
}
And
protected void btnSave_Click(object sender, EventArgs e)
{
foreach (GridDataItem gvr in RadGrid1.Items)
{
TextBox UpdateID = gvr["ID"].FindControl("txtID") as TextBox;
TextBox UpdateName = gvr["Name"].FindControl("txtName") as TextBox;
TextBox UpdateDept = gvr["Dept"].FindControl("txtDept") as TextBox;
con.Open();
SqlCommand cmd = new SqlCommand("update MyTable set Name = '" + UpdateName.Text + "', Dept = '" + UpdateDept.Text + "'where ID = " + UpdateID.Text, con);
cmd.ExecuteNonQuery();
con.Close();
lblresult.Text = " Details Updated successfully";
}
Can you suggest me how can i resolve this?
Thanks,
Venkata.
}