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

[Solved] get values of checkboxed in radgrid

2 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
giancarlo
Top achievements
Rank 1
giancarlo asked on 27 Aug 2009, 07:20 PM

my from is below.    on submit i would like to gather all the values from checkbox1
it comes from a database.    the idea is to  get all the items that the user keeps checked.





<

 

telerik:RadGrid ID="RadGrid1" runat="server"

 

 

DataSourceID="SqlDataSource1" GridLines="None" Skin="Sunset">

 

 

<MasterTableView autogeneratecolumns="False"

 

 

datasourceid="SqlDataSource1">

 

 

<RowIndicatorColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</RowIndicatorColumn>

 

 

<ExpandCollapseColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</ExpandCollapseColumn>

 

 

<Columns>

 

 

<telerik:GridTemplateColumn HeaderText=""

 

 

UniqueName="TemplateEditColumn">

 

 

<ItemTemplate>

 

 

<asp:CheckBox ID="CheckBox1" runat="server" Checked="True"></asp:CheckBox>

 

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridBoundColumn DataField="item" HeaderText="Accessories"

 

 

SortExpression="item" UniqueName="item">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="description" HeaderText="Description"

 

 

SortExpression="description" UniqueName="description">

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

</Columns>

 

 

</MasterTableView>

 

 

<HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"

 

 

Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Center"

 

 

Wrap="True" />

 

 

</telerik:RadGrid>

 

 

<asp:SqlDataSource ID="SqlDataSource1" runat="server"

 

 

ConnectionString="<%$ ConnectionStrings:wmConnectionString %>"

 

 

SelectCommand="wmUMEquipTableBySerial" SelectCommandType="StoredProcedure">

 

 

<SelectParameters>

 

 

<asp:QueryStringParameter DefaultValue="" Name="serial" QueryStringField="ID"

 

 

Type="String" />

 

 

</SelectParameters>

 

 

</asp:SqlDataSource>

 

 

<br />

 

Other options that you have installed

<br />

 

 

&nbsp;<asp:TextBox ID="TextBox1" runat="server" Width="610px" Height="122px"

 

 

TextMode="MultiLine"></asp:TextBox><br /><br />

 

 

<asp:CheckBox ID="CheckBox2" runat="server"

 

 

Text="Send me information about my trade-in options" /><br />

 

 

<asp:CheckBox ID="CheckBox3" runat="server"

 

 

Text="Send me information about consigning my mill on this website" /><br /><br />

 

 

<asp:Button ID="Button1" runat="server" Text="Submit" />&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />

 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Aug 2009, 04:29 AM
Hi Giancarlo,

Try the following code snippet in order to retrieve the row values of checked rows.

C#:
 
protected void Button1_Click(object sender, EventArgs e) 
    foreach( GridDataItem item in RadGrid1.MasterTableView.Items) 
    { 
        CheckBox chk = (CheckBox)item.FindControl("CheckBox1"); 
        if (chk.Checked) 
        { 
            // item represents the rows where the CheckBox1 is checked 
            Response.Write(item["item"].Text.ToString()); 
        } 
    } 

-Shinu.
0
giani
Top achievements
Rank 1
answered on 01 Sep 2009, 08:13 PM
so it will do like a loop and gather each item at a time?
Tags
Grid
Asked by
giancarlo
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
giani
Top achievements
Rank 1
Share this question
or