Connecting Tech Pros Worldwide Help | Site Map

detilsview problem with EditItemTemplate

Member
 
Join Date: Jan 2009
Posts: 57
#1: Jan 27 '09
HI All,

I have a details view in which i have a template column which contains a item template which contains a label(lblUser).

i am displaying some values on the label using

((Label)DetailsView1.FindControl("lblUser")).Text= UserLevel;

everything is fine till now...

now i want to add a EditItemTemplate to this.

As soon as i add a EditItemTemplate the above line throws the error(Object reference not set to an instance of an object.)(null referance exception)

i think it is not able to find the lblUser control now but why?????

can someone help me on this please......

Regards,

Vineet

below is the code for my detailsview


<asp:DetailsView Runat="Server" ID="DetailsView1" FieldHeaderStyle-Font-Bold="true"
FieldHeaderStyle-HorizontalAlign="Right" DefaultMode="ReadOnly"
AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
AutoGenerateInsertButton="True" AutoGenerateRows="False" BorderStyle="None"
BorderWidth="1px" CaptionAlign="Left" CellPadding="3" CssClass="Normal"
EmptyDataText="There are no records." Visible="False">

<FieldHeaderStyle HorizontalAlign="Right" Font-Bold="True" ></FieldHeaderStyle>
<Fields>


<asp:TemplateField HeaderText="UserLevel">
<EditItemTemplate></EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblUser" runat="server" Text='<%# Bind("UserLevel") %>'></asp:Label>
</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:Label ID="lblStatus" runat="server" Text='<%# Bind("StatusLevel") %>'></asp:Label>
</ItemTemplate>


</asp:TemplateField>

<asp:TemplateField HeaderText="ActionLevel">
<ItemTemplate>
<asp:Label ID="lblAction" runat="server" Text='<%# Bind("ActionLevel") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="TypeLevel">
<ItemTemplate>
<asp:Label ID="lblType" runat="server" Text='<%# Bind("TypeLevel") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

</Fields>
</asp:DetailsView>
Member
 
Join Date: Jan 2009
Posts: 57
#2: Jan 27 '09

re: detilsview problem with EditItemTemplate


also even if i try to change the defoultmode of the detailsview from "insert" to anything ele it throws me the same exception..


please help people
Reply