Changing Toggle button text by it's index

2 posts, 0 answers
  1. Dwayne Moore
    Dwayne Moore avatar
    3 posts
    Member since:
    Sep 2012

    Posted 21 Nov 2011 Link to this post

    I'm using the Radbutton with a checkbox toggle type and standardbutton button type.  I capture the text of the selected button(which are 3 types(fax,email,both-in that order).  I save the selected text to a database which is great.  I'm then trying to recall the data and assign the correct text to the button.  If the database text matches the indexed text, once I itterate through the control, I assign the ToggleStates(index).Text = Database text.  This doesn't seem to be working for me.  Below is a copy of my html and code behind.  Any help on this would be greatly appreciated.

     

     

    <telerik:RadButton ID="btnToggle2" CausesValidation="false" runat="server" ToggleType="CheckBox" ButtonType="StandardButton" Skin="Forest"

     

     

     

    AutoPostBack="False" >

     

     

     

    <ToggleStates>

     

     

     

    <telerik:RadButtonToggleState Text="Fax" Width="55px" />

     

     

     

    <telerik:RadButtonToggleState Text="Email" Width="55px" />

     

     

     

    <telerik:RadButtonToggleState Text="Both" Width="55px" />

     

     

     

    </ToggleStates>

     

     

     

    </telerik:RadButton>

    <<here i'm assigning the text to the correct indexed button>>

     

    If

     

     

    Not IsDBNull(dt.Rows(0).Item("ZZ_ACH_VIA")) Then

     

    btnCorrespondenseACH.Checked =

     

    True

     

     

     

    Dim index As Integer = 0

     

     

     

    If Not IsDBNull(dt.Rows(0).Item("ZZ_ACH_VIA")) Then

     

    index = FindToggleStates(dt.Rows(0).Item(

     

    "ZZ_ACH_VIA"), btnToggle2)

     

     

     

    'btnToggle2.SelectedToggleStateIndex = index

     

     

     

    End If

     

    btnToggle2.ToggleStates(index).Selected =

     

    True

     

    btnToggle2.ToggleStates(index).Text = dt.Rows(0).Item(

     

    "ZZ_ACH_VIA")

     

     

     

    End If

     


    << I used the function below to get the correct index by the text matching the button text.>>

    Function

     

     

    FindToggleStates(strText As String, oBtn As Telerik.Web.UI.RadButton) As Integer

     

     

     

    Dim iRetVal As Integer = 0

     

     

     

    For i As Integer = 0 To oBtn.ToggleStates.Count - 1

     

     

     

    If String.Compare(oBtn.ToggleStates.Item(i).Text, strText, True) = 0 Then

     

    iRetVal = i

     

     

    Exit For

     

     

     

    End If

     

     

     

    Next

     

     

     

    Return iRetVal

     

     

     

    End Function

     


  2. Dwayne Moore
    Dwayne Moore avatar
    3 posts
    Member since:
    Sep 2012

    Posted 21 Nov 2011 Link to this post

    Figured it out.  If I just set the text and not worry about setting the correct index, it gets me the desired result.

    Thanks
Back to Top