Hi,
I am using a dropdown list in gridview and populating it from database.However ,i am getting "object reference not set to an instance ..." error even though i have reference.
I have two more similar drop down list and they are working perfectly.
I am uploading the options for the dropdownlist from a "tab delimited" text file for all the dropdown list.
I am not getting where exactly the problem is.
please help me solve this.
<asp:TemplateField HeaderText="Property" HeaderStyle-Wrap="false">
<ItemTemplate>
<asp:Label ID="lblProperty" runat="server" Text='<%#Eval("Property")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblProperty" runat="server" Visible="false" Text='<%#Eval("Property") %>'></asp:Label>
<asp:DropDownList ID="ddlPropertyEdit" runat="server"></asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlPropertyFoot" runat="server">
</asp:DropDownList>
</FooterTemplate>
<HeaderStyle Wrap="True"></HeaderStyle>
</asp:TemplateField>
ddlProperty = new DropDownList();
ddlProperty = (DropDownList)e.Row.FindControl("ddlPropertyEdit");
GridSource = new DataSet();
GridSource = BusinessObj.GridBind(SelectedMonth, "Property");// Get the values from database.
ddlProperty.DataSource = GridSource;
ddlProperty.DataTextField = "Property";
ddlProperty.DataValueField = "Property";
ddlProperty.DataBind();
ddlProperty.Items.Insert(0, new ListItem("-Select Property-", "0"));
ddlProperty.Items.FindControl((e.Row.FindControl("lblProperty") as Label).Text).Selected=true;