J
John Smith
I have this code:
<asp:datagrid id="dg1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="SM">
<ItemTemplate>
<asp:Label id="Label2" runat="server" Text='<%#
Container.DataItem("SM") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<aspropDownList id="ddlSM" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="ddlSM_SelectedIndexChanged">
<asp:ListItem>... select</asp:ListItem>
<asp:ListItem Value="1000">1000 - AAA</asp:ListItem>
<asp:ListItem Value="2000">2000 - BBB</asp:ListItem>
<asp:ListItem Value="3000">3000 - CCC</asp:ListItem>
<asp:ListItem Value="4000">4000 - DDD</asp:ListItem>
<asp:ListItem Value="5000">5000 - EEE</asp:ListItem>
<asp:ListItem Value="6000">6000 - FFF</asp:ListItem>
</aspropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
But, when I execute this code inside Page_Load() :
Dim ddlSM As DropDownList = dg1.FindControl("ddlSM")
it returns Nothing (null). Why?
<asp:datagrid id="dg1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="SM">
<ItemTemplate>
<asp:Label id="Label2" runat="server" Text='<%#
Container.DataItem("SM") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<aspropDownList id="ddlSM" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="ddlSM_SelectedIndexChanged">
<asp:ListItem>... select</asp:ListItem>
<asp:ListItem Value="1000">1000 - AAA</asp:ListItem>
<asp:ListItem Value="2000">2000 - BBB</asp:ListItem>
<asp:ListItem Value="3000">3000 - CCC</asp:ListItem>
<asp:ListItem Value="4000">4000 - DDD</asp:ListItem>
<asp:ListItem Value="5000">5000 - EEE</asp:ListItem>
<asp:ListItem Value="6000">6000 - FFF</asp:ListItem>
</aspropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
But, when I execute this code inside Page_Load() :
Dim ddlSM As DropDownList = dg1.FindControl("ddlSM")
it returns Nothing (null). Why?