This is a migrated thread and some comments may be shown as answers.

Changing Toggle button text by it's index

1 Answer 61 Views
Button
This is a migrated thread and some comments may be shown as answers.
Dwayne Moore
Top achievements
Rank 1
Dwayne Moore asked on 21 Nov 2011, 09:26 PM
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

 


1 Answer, 1 is accepted

Sort by
0
Dwayne Moore
Top achievements
Rank 1
answered on 21 Nov 2011, 09:35 PM
Figured it out.  If I just set the text and not worry about setting the correct index, it gets me the desired result.

Thanks
Tags
Button
Asked by
Dwayne Moore
Top achievements
Rank 1
Answers by
Dwayne Moore
Top achievements
Rank 1
Share this question
or