3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by croker10
0

This code may help you:

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
      GridViewRow r = this.GridView1.Controls[0].Controls[e.RowIndex] as GridViewRow;
      TextBox t=  r.Controls[cell_index].Controls[control_index] as Text Box;
     }

This Syntax for Grid View:

GridView.Controls(0) ------ Table

GridView.Controls(0).Controls(index) ------ GridViewRow

GridView.Controls(0).Controls(index).Controls(index) ------ TableCell. For BoundField, we can use

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

0

My code is:-

TextBox tname =(TextBox ) GridView1.Rows[e.RowIndex].Cells[2].Controls[0];
        ds.Tables[0].Rows[e.RowIndex ][1] = tname.Text;
        TextBox tgender = (TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0] ;
        ds.Tables[0].Rows[e.RowIndex][2] = tgender.Text;

when i run the application then it throwing an exception: Unable to cast object of type
'System.Web.UI.WebControls.DataControlLinkButton' to type 'System.Web.UI.WebControls.TextBox'.

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

0

pharindra,

Can you please supply your code for the the GridView? That would help a lot in trying to find any problems that may be in the code.

Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.