Hi,
i try to change the display value of a radiobuttonlist embedded in a
gridview, but only in normal mode. In edit mode, the radiobuttonlist must
appears.
With this code below, i get what i want in normal mode (displayed values
(yes/no) are ok), but when i try to edit the row, i get:
"Object reference not set to an instance of an object."
at line: lbl.Text = "yes"
So, what's wrong here?
By the way, i also tried with:
If (e.Row.RowState And DataControlRowS tate.Normal) =
DataControlRowS tate.Normal Then
....
and with:
'If (e.Row.RowState And DataControlRowS tate.Normal) = 0 Then
.....
but same error ..
Thanks
Ben
<asp:TemplateFi eld>
<EditItemTempla te>
<asp:RadioButto nList ID="r1" SelectedValue=' <%# Bind("myfield") %>'
runat="server">
</asp:RadioButton List>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Labelvp" runat="server" Text='<%# Bind("myfield")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
Protected Sub GridView1_RowDa taBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Grid ViewRowEventArg s) Handles
GridView1.RowDa taBound
If e.Row.RowType = DataControlRowT ype.DataRow Then
Dim mf As Boolean = DataBinder.Eval (e.Row.DataItem , "myfield")
Dim lbl As Label = e.Row.FindContr ol("Labelvp")
If myfield = True Then
lbl.Text = "yes"
Else
lbl.Text = "no"
End If
End If
End Sub
i try to change the display value of a radiobuttonlist embedded in a
gridview, but only in normal mode. In edit mode, the radiobuttonlist must
appears.
With this code below, i get what i want in normal mode (displayed values
(yes/no) are ok), but when i try to edit the row, i get:
"Object reference not set to an instance of an object."
at line: lbl.Text = "yes"
So, what's wrong here?
By the way, i also tried with:
If (e.Row.RowState And DataControlRowS tate.Normal) =
DataControlRowS tate.Normal Then
....
and with:
'If (e.Row.RowState And DataControlRowS tate.Normal) = 0 Then
.....
but same error ..
Thanks
Ben
<asp:TemplateFi eld>
<EditItemTempla te>
<asp:RadioButto nList ID="r1" SelectedValue=' <%# Bind("myfield") %>'
runat="server">
</asp:RadioButton List>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Labelvp" runat="server" Text='<%# Bind("myfield")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
Protected Sub GridView1_RowDa taBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Grid ViewRowEventArg s) Handles
GridView1.RowDa taBound
If e.Row.RowType = DataControlRowT ype.DataRow Then
Dim mf As Boolean = DataBinder.Eval (e.Row.DataItem , "myfield")
Dim lbl As Label = e.Row.FindContr ol("Labelvp")
If myfield = True Then
lbl.Text = "yes"
Else
lbl.Text = "no"
End If
End If
End Sub
Comment