V
Vishal
Hello,
This should be simple question. I thought I could solve it
by my own, but unfortunaly I am not able. I have a
datagrid with several asp:TemplateColumn's. In that
template I have the <ItemTemplate> and the
<EditItemTemplate> template. Now I would like to retrieve
the value of the <ItemTemplate>. The template looks like
this:
<ItemTemplate>
<asp:Label text='<%# Container.DataItem("Banned") %>'
Runat="server" ID="lblBanned"></asp:Label>
</ItemTemplate>
However when I call my code then I get this error message:
Object reference not set to an instance of an object.
In this line -> If lblBanned.Text = "True" Then
Sub dgUsers_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs)
If (e.Item.ItemType = ListItemType.EditItem) Then
Dim lblBanned As Label = CType(e.Item.Cells
(11).FindControl("lblBanned"), Label)
If lblBanned.Text = "True" Then
....
Where is my fault?
This should be simple question. I thought I could solve it
by my own, but unfortunaly I am not able. I have a
datagrid with several asp:TemplateColumn's. In that
template I have the <ItemTemplate> and the
<EditItemTemplate> template. Now I would like to retrieve
the value of the <ItemTemplate>. The template looks like
this:
<ItemTemplate>
<asp:Label text='<%# Container.DataItem("Banned") %>'
Runat="server" ID="lblBanned"></asp:Label>
</ItemTemplate>
However when I call my code then I get this error message:
Object reference not set to an instance of an object.
In this line -> If lblBanned.Text = "True" Then
Sub dgUsers_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs)
If (e.Item.ItemType = ListItemType.EditItem) Then
Dim lblBanned As Label = CType(e.Item.Cells
(11).FindControl("lblBanned"), Label)
If lblBanned.Text = "True" Then
....
Where is my fault?