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

Multi row delete in grid view

1 Answer 62 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Azees
Top achievements
Rank 1
Azees asked on 06 Sep 2008, 04:54 AM
Hi 
 
     how to delete mulitiple rows in telerik grid view...
     i know how to delete in asp grid view....
     

    

<

asp:TemplateField>

<HeaderTemplate>CHOIX</HeaderTemplate>

<ItemTemplate><asp:CheckBox ID="chkSelect" runat="server" /></ItemTemplate>

</asp:TemplateField> 

protected

void btnDelete_Click(object sender, EventArgs e)

{

foreach (GridViewRow row in grdParascolaireAct.Rows)

{

CheckBox chk = (CheckBox)row.FindControl("chkSelect");

if (chk.Checked)

{

string uid = Convert.ToString(grdParascolaireAct.DataKeys[row.RowIndex].Value);

BLParascolaireAct.Harddelete_ParascolairAct(uid);

BindParascolaireAct();

}

}

}


 But in telerik grid in select option is differ from asp:grid
i cant set id in following taq
<telerik:GridClientSelectColumn UniqueName="column" ></telerik:GridClientSelectColumn>

so how to delete mutiple rows in telerik grid

plz reply

azees

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Sep 2008, 07:56 AM
Hi Azees,

You can achieve the same functionality in RadGrid using a GridTemplateColumn. Place a CheckBox in the ItemTemplate of the template column and in the button click event you can loop through each GridDataItem in the Grid and access the CheckBox value.


ASPX:
         <telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="TempCol"
                       <ItemTemplate> 
                           <asp:CheckBox ID="chkSelect" runat="server" /> 
                       </ItemTemplate> 
                     </telerik:GridTemplateColumn> 

CS:
protected void Button1_Click(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid2.MasterTableView.Items) 
        { 
            CheckBox chkbx = (CheckBox)item.FindControl("chkSelect"); 
            if (chkbx.Checked) 
            { 
               //to access the DataKeyName for the checked row 
                string key = item.GetDataKeyValue("KeyName").ToString(); 
               // perform the delete operation
            } 
        } 
    } 


Cheers
Shinu.
Tags
General Discussions
Asked by
Azees
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or