Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello sir,

I would like to ask that there is a grid in that grid I have taken dropdownlist in Itemtemplate field,I made one function i.e.
C#
filldropdown()
{
DataTable dt=new DataTable();
dt=clss.filldrop();
dropdownlist.datasource=dt;
dropdownlist.databind();
}

I am unable to fill dropdown beacuse The ID I want to call in the function to insert values from my database i.e. inside ItemTemplate.

Please help me to rectify my problem, how I can call ID of dropdown that is inside ItemTemplate of gridview.

Please guide me.

Thanks in advance.
Posted
Updated 29-Nov-11 7:28am
v2
Comments
RaisKazi 29-Nov-11 13:28pm    
Edited: 1) Formatting 2) Added "pre" tag.

1 solution

whenever you have control within a control's item/alternate-item template you can't access control directly
you need to extract inner control by using method FindControl() with main control.
i.e.
in your case it will be like this


C#
DropDownList list = (DropDownList) myGrid.FindControl("ddlName");
list.DataSource = dt;
list.DataBind();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900