Check all Row of Telerik Radgrid
Check all Row of Telerik Radgrid
In this article I am selecting all rows of Radgrid on single
check.
For this you have to specify dome properties :-
AllowMultiRowSelection="True",
using this property you can allow or denied its multiple selection.
<Selecting AllowRowSelect="true"></Selecting>
The checkbox control for radgrid
                   
<telerik:GridClientSelectColumn>
                   
</telerik:GridClientSelectColumn>
Step 1:Design web form .aspx page
<div>
        <asp:ScriptManager ID="ss" runat="server">
        </asp:ScriptManager>
        <telerik:RadGrid ID="RadGrid1"
OnNeedDataSource="RadGrid1_NeedDataSource"
runat="server"
            CellSpacing="0"
AllowPaging="True"
PageSize="10"
Width="97%"
AllowMultiRowSelection="True"
            GridLines="None">
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <ClientSettings EnableRowHoverStyle="true">
               
<Selecting
AllowRowSelect="true"></Selecting>
            </ClientSettings>
            <SelectedItemStyle
CssClass="SelectedItem"></SelectedItemStyle>
            <MasterTableView>
               
<Columns>
                   
<telerik:GridClientSelectColumn>
                   
</telerik:GridClientSelectColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </div>
Step 2:Logic on .Cs page
protected void
RadGrid1_NeedDataSource(object sender,
Telerik.Web.UI.GridNeedDataSourceEventArgs
e)
    {
        DataTable dt = new
DataTable();
       
dt.Columns.Add("Name");
       
dt.Columns.Add("Amount", typeof(Int32));
       
dt.Columns.Add("Phone");
       
dt.Columns.Add("UnitCount",
typeof(Int32));
       
dt.Rows.Add("Kandy", "12", "8802***2564",
"2");
       
dt.Rows.Add("Sam", "25", "545502*2544",
"4");
       
dt.Rows.Add("Izhar", "32", "95802*2452",
"4");
       
dt.Rows.Add("Vineet", "10", "88022564***",
"6");
       
RadGrid1.DataSource = dt;
    }

 
 
This works very well and it simple to the point
ReplyDelete