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

check box validation in radgrid

1 Answer 136 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sudheer
Top achievements
Rank 2
sudheer asked on 26 Dec 2008, 02:59 PM
HI

I have a radgrid in which check box  available for every row  .
At the top of the grid attach button available .Before click attach button i need to validate user to check atleast one checkbox in the radgrid

Looking for  help


Thanks

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 29 Dec 2008, 11:11 AM
Hello Sudheer,

Let me know whether the suggested code suits your scenario:
<telerik:GridTemplateColumn> 
    <HeaderTemplate> 
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> 
    </HeaderTemplate> 
    <ItemTemplate> 
        <asp:CheckBox ID="CheckBox1" runat="server" /> 
    </ItemTemplate> 
</telerik:GridTemplateColumn> 

protected void Button1_Click(object sender, EventArgs e) 
    bool found = false
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        if ((item.FindControl("CheckBox1"as CheckBox).Checked) 
            found = true
    if (!found) 
        RadAjaxManager1.Alert("Please select at least one checkbox!"); 

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
sudheer
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Share this question
or