I have a drop down list, which has first item hard coded and other are bind by sql data source. Now on C# code I want this drop down list's items count which I'm getting 1 always (the first hard coded list item). while this drop down list is properly showing all list item on browser. I'm not able to understand the exact problem.
<asp:DropDownList ID="ddlGroup" runat="server" DataSourceID="dsGroupListByUserId"
Width="100px" DataTextField="GroupName" DataValueField="GroupID" AppendDataBoundItems="True">
<asp:ListItem Value="0">N/A</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="dsGroupListByUserId" runat="server" ConnectionString="<%$ ConnectionStrings:EMSsql %>" SelectCommand="GetGroup_ByEventID" SelectCommandType="StoredProcedure" >
<SelectParameters>
<asp:SessionParameter DefaultValue="0" Name="EventID" SessionField="EventID" Type="Int64" />
</SelectParameters>
</asp:SqlDataSource>
And this is how i'm trying to fetch items count-
int ItemsCount = ddlGroup.Items.Count;