B
Ben
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 DataControlRowState.Normal) =
DataControlRowState.Normal Then
....
and with:
'If (e.Row.RowState And DataControlRowState.Normal) = 0 Then
.....
but same error ..
Thanks
Ben
<asp:TemplateField>
<EditItemTemplate>
<asp:RadioButtonList ID="r1" SelectedValue='<%# Bind("myfield") %>'
runat="server">
</asp:RadioButtonList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Labelvp" runat="server" Text='<%# Bind("myfield")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim mf As Boolean = DataBinder.Eval(e.Row.DataItem, "myfield")
Dim lbl As Label = e.Row.FindControl("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 DataControlRowState.Normal) =
DataControlRowState.Normal Then
....
and with:
'If (e.Row.RowState And DataControlRowState.Normal) = 0 Then
.....
but same error ..
Thanks
Ben
<asp:TemplateField>
<EditItemTemplate>
<asp:RadioButtonList ID="r1" SelectedValue='<%# Bind("myfield") %>'
runat="server">
</asp:RadioButtonList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Labelvp" runat="server" Text='<%# Bind("myfield")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim mf As Boolean = DataBinder.Eval(e.Row.DataItem, "myfield")
Dim lbl As Label = e.Row.FindControl("Labelvp")
If myfield = True Then
lbl.Text = "yes"
Else
lbl.Text = "no"
End If
End If
End Sub