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

How to add checkboxes at run time ?

3 Answers 133 Views
Button
This is a migrated thread and some comments may be shown as answers.
Madhu Palakurthi
Top achievements
Rank 1
Madhu Palakurthi asked on 30 Nov 2012, 04:46 AM
Hi,

I have a screen that will give search result ( Invoice no(s) ) and need to be binding in check box list.

this is the check box that i added in aspx page. but  I would like to show dynamically based on search result ( no of invoice no(s))

  <asp:TableCell CssClass="fls">
<telerik:RadButton ID="chkSearchResult" ToggleType="CheckBox" runat="server" Text="HQ09504">
       <ToggleStates>
            <telerik:RadButtonToggleState Text="HQ09504" PrimaryIconCssClass="rbToggleCheckboxChecked" />
           <telerik:RadButtonToggleState Text="HQ09504" PrimaryIconCssClass="rbToggleCheckbox" />
      </ToggleStates>
</telerik:RadButton>
</asp:TableCell>

Please give me sample code to generate check boxes at run time.

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Nov 2012, 05:28 AM
Hi,

Try the following code to achieve your scenario.
C#:
chkSearchResult.ToggleType = ButtonToggleType.CheckBox;
 chkSearchResult.ButtonType = RadButtonType.ToggleButton;
RadButtonToggleState state = new RadButtonToggleState();
 state.Text = "HQO9504";
 chkSearchResult.ToggleStates.Add(state);

Thanks,
Princy.
0
Madhu Palakurthi
Top achievements
Rank 1
answered on 30 Nov 2012, 06:06 AM
Hi Princy,

I modified logic as you mentioned above but it showing only one checkbox in display..

My code is :
<asp:TableFooterRow>
<asp:TableCell CssClass="fls">
  <telerik:RadButton ID="chkSearchResult" ToggleType="CheckBox" Text="DSAD" runat="server" >
  <ToggleStates></ToggleStates>                                                                  
  </telerik:RadButton>
</asp:TableCell>
</asp:TableFooterRow>
 
and code behind is :

chkSearchResult.ToggleType = ButtonToggleType.CheckBox
chkSearchResult.ButtonType = RadButtonType.ToggleButton
Dim state As New RadButtonToggleState()
For index As Integer = 1 To 10
    state.Text = "HQO9504" + (index.ToString())
Next
chkSearchResult.ToggleStates.Add(state)

Still its showing only one checkbox is named with "DSAD" . what is the purpose of loop the states and add in to toggle.
0
Princy
Top achievements
Rank 2
answered on 03 Dec 2012, 04:43 AM
Hi Moegal,

Following is the full code that I tried to add RadButtonToggleState dynamically to a RadButton.

ASPX:
<telerik:RadButton ID="chkSearchResult" ButtonType="ToggleButton" ToggleType="CheckBox" runat="server">
    <ToggleStates>
    </ToggleStates>
</telerik:RadButton>

C#:
protected void Page_Load(object sender, EventArgs e)
{
        RadButtonToggleState state1 = new RadButtonToggleState();
        state1.Text = "HQO95041";
        state1.PrimaryIconCssClass = "rbToggleCheckboxChecked";
        chkSearchResult.ToggleStates.Add(state1);
        RadButtonToggleState state2 = new RadButtonToggleState();
        state2.Text = "HQO95042";
        state2.PrimaryIconCssClass = "rbToggleCheckbox";
        chkSearchResult.ToggleStates.Add(state2);
}

Please elaborate your scenario if it doesn't helps.

Regards,
Princy.
Tags
Button
Asked by
Madhu Palakurthi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Madhu Palakurthi
Top achievements
Rank 1
Share this question
or