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

Discussion in 'ASP .Net' started by Ben, May 29, 2008.

  1. Ben

    Ben Guest

    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
     
    Ben, May 29, 2008
    #1
    1. Advertising

  2. Ben

    Ben Guest

    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 ...




    "Ben" <> schreef in bericht
    news:...
    > 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
    >
    >
    >
     
    Ben, May 29, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John J Lee
    Replies:
    3
    Views:
    525
    bruno at modulix
    Dec 1, 2005
  2. pvong
    Replies:
    3
    Views:
    803
    pvong
    Aug 7, 2007
  3. Edward Loper
    Replies:
    0
    Views:
    510
    Edward Loper
    Aug 7, 2007
  4. Leo Jay
    Replies:
    1
    Views:
    302
  5. Replies:
    2
    Views:
    103
    Tom Cole
    Aug 24, 2006
Loading...

Share This Page