I have created a DropDownList in asp.net with declaration in the aspx file as follows:
Expand|Select|Wrap|Line Numbers
- <asp:DropDownList ID="lbExtractType" runat="server">
- <asp:ListItem Value=" "></asp:ListItem>
- <asp:ListItem Value="apple">apple</asp:ListItem>
- <asp:ListItem Value="banana">banana</asp:ListItem>
- <asp:ListItem Value="orange">orange</asp:ListItem>
- <asp:ListItem Value="peach">peach</asp:ListItem>
- <asp:ListItem Value="pear">pear</asp:ListItem>
- <asp:ListItem Value="grape">grape</asp:ListItem>
- </asp:DropDownList>
Expand|Select|Wrap|Line Numbers
- DropDownList list = (DropDownList)Master.FindControl("ContentPlaceHolder1").FindControl("lbExtractType");
- string extractType = list.SelectedItem.Value;
- MessageBox.Show("Extract Type = " + extractType);
Expand|Select|Wrap|Line Numbers
- Server Error in '/WebSite1' Application.
- Object reference not set to an instance of an object.
- Line 161:
- Line 162: DropDownList list = (DropDownList)Master.FindControl("ContentPlaceHolder1").FindControl("lbExtractType");
- Line 163: string extractType = list.SelectedItem.Value;
- Line 164:
- Line 165: MessageBox.Show("Extract Type = " + extractType);
- Source File: c:\00 CADLine Projects\AJAX\WebSite1\Default.aspx.cs Line: 163
Any help will be greatly appreciated please?
Thank you.
M :)