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

[Solved] Get checkboxlist value

1 Answer 200 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ghadeer
Top achievements
Rank 1
ghadeer asked on 24 Jun 2009, 11:03 AM
Hi All,
I have RadGrid with itemtemplate for survey questions ,user will choose answer from  checboxlist,So how can I get the selected value of checkboxlist to save in database


thanks
ghadeer

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 24 Jun 2009, 12:14 PM
Hi Ghadeer,

Try the following code snippet in order to access the CheckBoxList placed in ItemTemplate of GridTemplateColumn.

CS:
 
protected void Button1_Click(object sender, EventArgs e)  
{  
    foreach (GridDataItem item in RadGrid1.Items)  
    {  
        CheckBoxList checkList = (CheckBoxList)item.FindControl("CheckBoxList1"); //Get reference to CheckBoxList  
        foreach (ListItem MyItem in checkList.Items) // Loop through the CheckBoxList Items  
        {  
            if (MyItem.Selected == true)  
            {  
                Label1.Text = Label1.Text + MyItem.Text; // Selected Items  
            }  
        }  
    }  

Thanks,
Princy.
Tags
Grid
Asked by
ghadeer
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or