views:

154

answers:

1

i have a datalist and inside it there is many rows and in one of these rows i have a gridview,. i can say that it's like the following

<DataList>
  <tr>
      <td> [textbox1 control]  </td>
  </tr>
  <tr>
      <td> [textbox2 control]  </td>
  </tr>
  <tr>
    <td> 
       <gridview/>
    </td>
  </tr>
</DataList>

my problem is when i'm in gridview RowCommand handler i want to get the data that exist in [textbox1 control] and [textbox1 control]

i do the following

DataListItem dataListItem = (DataListItem)((GridView)sender).Parent.Parent.Parent.Parent;
string txt = ((TextBox)dataListItem.FindControl([textbox1 control])).Text.Trim();

but is this the only way to ?

A: 

Would something like this work?

string txt = ((TextBox)DataList.Items[0].FindControl([textbox1 control])).Text.Trim();
Abe Miessler
this could will work if current item is 0 but if is another one ... how can i know ?
Space Cracker