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

[Solved] radgridBox selected rows to radlistBox

4 Answers 176 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hilmi
Top achievements
Rank 1
Hilmi asked on 15 May 2013, 07:18 AM
How can i select a radgrid column with checkbox and add that selected columns to a radlist?  Ä° am new on telerik and i cant do it for a while... please help

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 May 2013, 07:48 AM
Hi,

I guess you want to add a selected column text inside the RadListBox on checkbox check.

C#:
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
    CheckBox chk = (CheckBox)sender;
    GridDataItem Data = (GridDataItem)chk.NamingContainer;
    string Value= Data["UniqueName"].Text;
    RadListBox list = (RadListBox)Data.FindControl("RadlistBox1");
    RadListBoxItem item = new RadListBoxItem(Value, Value);
    list.Items.Add(item);
}

Thanks,
Shinu.
0
Hilmi
Top achievements
Rank 1
answered on 15 May 2013, 08:06 AM
<Columns>
        <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn">
        <ItemTemplate>
          <asp:CheckBox ID="CheckBox1" runat="server" 
            AutoPostBack="True" />
        </ItemTemplate>
        <HeaderTemplate>
          <asp:CheckBox ID="headerChkbox" runat="server"
            AutoPostBack="True" />
        </HeaderTemplate>
      </telerik:GridTemplateColumn>
      
        <telerik:GridBoundColumn DataField="ProductName" FilterControlAltText="Filter ProductName column" HeaderText="ProductName" SortExpression="ProductName" UniqueName="ProductName">
            <ColumnValidationSettings>
                <ModelErrorMessage Text="" />
            </ColumnValidationSettings>
        </telerik:GridBoundColumn>
    </Columns>

this is my columns and i want to add product names which are checked to radlist yes you are right. but it doesnt work...where is my mistake?

thank you...
0
Shinu
Top achievements
Rank 2
answered on 16 May 2013, 03:40 AM
Hi,

I guess your RadListBox is outside the Radgrid. Please check the following code snippet.

C#:
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
    CheckBox chk = (CheckBox)sender; //accessing the CheckBox
    GridDataItem Data = (GridDataItem)chk.NamingContainer; //accessing the GridDataItem in which the checked checkbox resides
    string Value= Data["UniqueName"].Text; // getting value of the Bound column in the row
    
    RadListBoxItem item = new RadListBoxItem(Value, Value);// creating the ListBoxItem with BoundColumn's Text
    RadlistBox1.Items.Add(item); //adding the item in RadListBox
}

Thanks,
Shinu.
0
Hilmi
Top achievements
Rank 1
answered on 16 May 2013, 06:26 AM
Thanks, it is working..
Tags
Grid
Asked by
Hilmi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Hilmi
Top achievements
Rank 1
Share this question
or