469,314 Members | 2,208 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,314 developers. It's quick & easy.

e.Item.FindControl("DropdownId") Returning Null

Hi Group,

I have a datagrid with dropdown in my application.
I want to fill the data in dropdown by an ArrayList
for that I am using "e.Item.FindControl("DropdownId")"
but this function is returning NULL THUS I m getting exception
"Object Refrence not set to an Instance to Object",

Here is the code I wrote (ASP.NET 1.1)...

Hope I get some help from you,

///Cdoe Behind
private void dataGrid1_ItemDataBound(object sender,
DataGridItemEventArgs e)
{

if(e.Item.ItemType == ListItemType.Footer)
{

System.Web.UI.WebControls.DropDownList drp = new
DropDownList();
drp = (DropDownList)e.Item.FindControl("listAnup");
drp.DataSource=newArrayList;//This Statement throwing exception
drp.DataBind();
}

}


///aspx code

<asp:datagrid id=dataGrid1 style="Z-INDEX: 101; LEFT: 256px; POSITION:
absolute; TOP: 8px" runat="server" ShowFooter="True" CaptionAlign="Top"
Caption="Hello" BackColor="RosyBrown" AllowPaging="True" Height="256px"
Width="70%" DataSource="<%# dataSet1 %>" PageSize="2" CellPadding="2"
CellSpacing="2">
<FooterStyle ForeColor="#FFFF80" BorderColor="#E0E0E0"
BackColor="Gray"></FooterStyle>
<SelectedItemStyle ForeColor="#804040" BorderColor="#FFE0C0"
BackColor="Aqua"></SelectedItemStyle>
<EditItemStyle ForeColor="#FFE0C0"
BackColor="#C0FFC0"></EditItemStyle>
<AlternatingItemStyle ForeColor="DarkOliveGreen"
BackColor="#FFC080"></AlternatingItemStyle>
<ItemStyle ForeColor="#404040" BackColor="Khaki"></ItemStyle>

Mar 25 '06 #1
1 2706
MFB
I don't see that you have a control named *listAnup* in the footer which
is where you're looking for it. For that matter you don't have one
called that at all in your code. Is this all of the code?

Mar 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Sara | last post: by
reply views Thread by George Durzi | last post: by
9 posts views Thread by Thomas Mlynarczyk | last post: by
1 post views Thread by sbowman | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.