Is it possible to get a control by ID like e.Item.Cells[1].Controls["toto"]

S

SoftLion

Is it possible to get a control by ID like that :

void DataGrid1_ValidateEdit(object sender, DataGridCommandEventArgs e)
{
object obj = e.Item.Cells[2].Controls["myControlID"];
instead of:
object obj = e.Item.Cells[2].Controls[0];
}

Or is there a way to do this easily ?
 
G

George

Well,

i have never done it that way but I know this way works:

dim workDropDownList as dropdownlist

workDropDownList = CType(e.Item.FindControl("ddlDivision"),
DropDownList)




the point being the FindControl function will return a reference to
the control with the ID specified.

I hope this helps.
George
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top