can't change radiobuttonlist displayed value in normal mode of gridview

  • Thread starter Thread starter Ben
  • Start date Start date
B

Ben

Hi,

The gridview contains a radiobuttonlist with boolean values (true/false)
coming from a database.

In normal mode, the gridview displays True or False for that field.
What i want is to change True' and 'False' by 'Yes' and 'No' in normal mode.
I tried this, but still get True / False.

Thanks for help
Ben

<asp:TemplateField>
<EditItemTemplate>
<asp:RadioButtonList ID="r1" SelectedValue='<%# Bind("myfield") %>'
runat="server">
</asp:RadioButtonList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label31" runat="server" Text='<%# Bind("myfield")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
------------------------------
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If e.Row.RowState And DataControlRowState.Normal =
DataControlRowState.Normal Then
If e.Row.RowType = DataControlRowType.DataRow Then
Dim lb As Label
lb = CType(e.Row.FindControl("label31"), Label)
If lb.Text = "True" Then
lb.Text = "Yes"
Else
lb.Text = "No"
End If
End If
End If
 
I tried this:

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
If (e.Row.RowState And DataControlRowState.Normal) =
DataControlRowState.Normal Then
If e.Row.RowType = DataControlRowType.DataRow Then
Dim st As String
st = e.Row.Cells(5).Text
If st = "True" Then
e.Row.Cells(5).Text = "Yes"
Else
e.Row.Cells(5).Text = "No"
End If
End If
End If
End Sub

Now, i have Yes/No in normal mode, but also in edit mode instead of the
radiobuttonlist which has gone ...
 
Back
Top