How to get data from datalist?

How to get current selected data in datalist from gridview inside it?

  • 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 ?

  • Answer:

    Would something like this work? string txt = ((TextBox)DataList.Items[0].FindControl([textbox1 control])).Text.Trim();

Amr Badawy at Stack Overflow Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.