Hello Admins,
I'm having a location grid user control. Each grid item contains check boxes. I can select the multiple check boxes and delete all at once when i click on the link button which i have defined. Everything is working fine. But, if i don't select any of the checkboxes to delete or there is no data in the grid, how to do the client side validation for this scenario. Please help me in this regard.
And also whenever i select any check boxes, post back is happening. How to overcome this problem as well.
My checkbox code:
<telerik:GridTemplateColumn UniqueName="CheckboxId" HeaderText="View" DataField="View" >
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true"/>
</ItemTemplate>
</telerik:GridTemplateColumn>
My checkbox code behind:
foreach (GridDataItem item in rgLocations.MasterTableView.Items)
{
chk = (CheckBox)item.FindControl("CheckBox1");
if (!chk.Checked)
{
DataRow newRowAdd = myDataTable.NewRow();
newRowAdd["Id"] = item["Id"].Text;
newRowAdd["Name"] = item["Name"].Text;
newRowAdd["CTID"] = item["CTID"].Text;
myDataTable.Rows.Add(newRowAdd);
myDataTable.AcceptChanges();
}
}
rgLocations.DataSource = myDataTable.DefaultView;
rgLocations.Rebind();
My link button code:
<asp:LinkButton ID="lnkDeleteLoc" runat="server" OnClick="lnkDeleteLoc_Click">Delete the Location(s)</asp:LinkButton>
I'm having a location grid user control. Each grid item contains check boxes. I can select the multiple check boxes and delete all at once when i click on the link button which i have defined. Everything is working fine. But, if i don't select any of the checkboxes to delete or there is no data in the grid, how to do the client side validation for this scenario. Please help me in this regard.
And also whenever i select any check boxes, post back is happening. How to overcome this problem as well.
My checkbox code:
<telerik:GridTemplateColumn UniqueName="CheckboxId" HeaderText="View" DataField="View" >
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true"/>
</ItemTemplate>
</telerik:GridTemplateColumn>
My checkbox code behind:
foreach (GridDataItem item in rgLocations.MasterTableView.Items)
{
chk = (CheckBox)item.FindControl("CheckBox1");
if (!chk.Checked)
{
DataRow newRowAdd = myDataTable.NewRow();
newRowAdd["Id"] = item["Id"].Text;
newRowAdd["Name"] = item["Name"].Text;
newRowAdd["CTID"] = item["CTID"].Text;
myDataTable.Rows.Add(newRowAdd);
myDataTable.AcceptChanges();
}
}
rgLocations.DataSource = myDataTable.DefaultView;
rgLocations.Rebind();
My link button code:
<asp:LinkButton ID="lnkDeleteLoc" runat="server" OnClick="lnkDeleteLoc_Click">Delete the Location(s)</asp:LinkButton>