GridView Update doesnt seem to work

S

sri_san

Hello,
I have a gridview in a usercontrol which is inside another
usercontrol. I am facing a problem when I click on "Update" in the
sense, inside the onRowUpdating event - the gridview.editindex is -1
and is unable to find the controls from the edittemplate. The same
flow works fine when the gridview is coded in a aspx page instead of
inside a nested usercontrol. The controls are declared in the html view
and is not dynamic.
The code is outlined as below:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
bindData();
}
}
protected void newsGridView_RowEditing(object sender,
GridViewEditEventArgs e)
{
newsGridView.EditIndex = e.NewEditIndex;
bindData();
}
protected void newsGridView_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
// In here, the gv.editIndex is reset to -1 with
gv.Rows.Count =0.
TextBox txtInput =
(TextBox)(gvStudents.Rows[e.RowIndex].FindControl("txtInput"))).Text);

}

The intriguing part is the same code works fine on a aspx page.

Any help would be appreciated!


Thanks,
Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top