digish devassy
Top achievements
Rank 1
digish devassy
asked on 28 Feb 2012, 01:43 PM
I am able to check all the checkboxes. But When I tried to retrieve all the checked boxes, checked, I am able to get the checkboxes ticked only in the first page.
other page value are not getting retrieved using the code:
for (int i = 0; i < rdNew.Items.Count; i++)
{
CheckBox chkSelected = (CheckBox)rdNew.Items[i].FindControl("chkSelected");
String Id = rdNew.Items[i]["id"].Text;
if (chkSelected.Checked && chkSelected != null)
{
if (list.Count == 0)
{
list.Add(Id);
}
}
}
I am not getting the total list, of the users checked.
other page value are not getting retrieved using the code:
for (int i = 0; i < rdNew.Items.Count; i++)
{
CheckBox chkSelected = (CheckBox)rdNew.Items[i].FindControl("chkSelected");
String Id = rdNew.Items[i]["id"].Text;
if (chkSelected.Checked && chkSelected != null)
{
if (list.Count == 0)
{
list.Add(Id);
}
}
}
I am not getting the total list, of the users checked.
5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 29 Feb 2012, 05:22 AM
Hello,
I cannot reproduce the issue at my end. Check the following help documentation.
Persisting CheckBox control state in GridTemplateColumn on rebind.
-Shinu.
I cannot reproduce the issue at my end. Check the following help documentation.
Persisting CheckBox control state in GridTemplateColumn on rebind.
-Shinu.
0
digish devassy
Top achievements
Rank 1
answered on 29 Feb 2012, 06:36 AM
HI shinu,
I respect your replies,
I am in a hurry. All my requirement is, how to loop through all the checked checkboxes in radgrid and get the id associated with the checkboxed rows. I am not finding a solution. my client has bought your stuff. It is painful to see that, I get such non serious replies from telerik forum
thanks,
I respect your replies,
I am in a hurry. All my requirement is, how to loop through all the checked checkboxes in radgrid and get the id associated with the checkboxed rows. I am not finding a solution. my client has bought your stuff. It is painful to see that, I get such non serious replies from telerik forum
thanks,
0
Solucky
Top achievements
Rank 2
answered on 29 Feb 2012, 07:07 AM
Hi,
i hope it will help
Regards,
Bhavik Solucky
i hope it will help
//MakeAllowPaging false and collect all data
radVenues.AllowPaging = false;
radVenues.Rebind();
List<int> CheckedItemlist = new List<int>(); var Count=(from Item in radVenues.MasterTableView.Items.Cast<GridDataItem>() where ((CheckBox)Item.FindControl("chkLoop")).Checked=true select AddItemIdinList(Item,CheckedItemlist)).Count();
//MakeAllowPaging True
radVenues.AllowPaging = true;
radVenues.Rebind();
public bool AddItemIdinList(GridDataItem Item, List<int> Itemlist) { int id=0; int.TryParse(Item.GetDataKeyValue("ID").ToString(), out id); Itemlist.Add(id); return true; }Bhavik Solucky
0
Jayesh Goyani
Top achievements
Rank 2
answered on 29 Feb 2012, 07:15 AM
Hello,
Let me know if any concern.
Thanks,
Jayesh Goyani
<telerik:RadGrid ID="grdShipments" Skin="Office2007" runat="server" GridLines="None" AllowPaging="True" PageSize="2" AllowSorting="True" AutoGenerateColumns="False" ShowStatusBar="true" AllowFilteringByColumn="true" OnNeedDataSource="grdShipments_NeedDataSource"> <MasterTableView CommandItemDisplay="Top" EnableNoRecordsTemplate="true" ShowHeader="true" ShowHeadersWhenNoRecords="true"> <Columns> <telerik:GridTemplateColumn> <ItemTemplate> <asp:CheckBox ID="chkI" runat="server" /> </ItemTemplate> <HeaderTemplate> <asp:CheckBox ID="chkH" runat="server" AutoPostBack="true" oncheckedchanged="chkH_CheckedChanged" /> </HeaderTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="Shipper" HeaderText="Shipper" UniqueName="Shipper" AllowFiltering="true"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ShipDate" HeaderText="ShipDate" UniqueName="ShipDate" AllowFiltering="true"> </telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:RadGrid> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />protected void grdShipments_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("Shipper", typeof(string)); dt.Columns.Add("ShipDate", typeof(DateTime)); dt.Rows.Add("Shipper1", DateTime.Now.AddDays(1)); dt.Rows.Add("Shipper2", DateTime.Now.AddDays(2)); dt.Rows.Add("Shipper3", DateTime.Now.AddDays(3)); dt.Rows.Add("Shipper1", DateTime.Now.AddDays(1)); dt.Rows.Add("Shipper2", DateTime.Now.AddDays(2)); dt.Rows.Add("Shipper3", DateTime.Now.AddDays(3)); grdShipments.DataSource = dt; } protected void chkH_CheckedChanged(object sender, EventArgs e) { CheckBox chkH = sender as CheckBox; foreach (GridDataItem item in grdShipments.MasterTableView.Items) { CheckBox chkI = item.FindControl("chkI") as CheckBox; chkI.Checked = chkH.Checked; } } protected void Button1_Click(object sender, EventArgs e) { GridHeaderItem hItem = grdShipments.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem; if (hItem != null) { CheckBox chkH = hItem.FindControl("chkH") as CheckBox; if (chkH.Checked) { grdShipments.AllowPaging = false; grdShipments.Rebind(); string strTemp = grdShipments.Items.Count.ToString(); foreach (GridDataItem item in grdShipments.Items) { // Do your Logic Here } grdShipments.AllowPaging = true; grdShipments.Rebind(); foreach (GridDataItem item in grdShipments.MasterTableView.Items) { CheckBox chkI = item.FindControl("chkI") as CheckBox; chkI.Checked = chkH.Checked; } } } }Let me know if any concern.
Thanks,
Jayesh Goyani
0
Jaya
Top achievements
Rank 1
answered on 20 Feb 2015, 10:06 AM
Hi
Jayesh Goyani
I have Telerik Radgrid following Fields
Name,Empno last field checkbox like this
<telerik:GridTemplateColumn HeaderText="Status">
<ItemTemplate>
<asp:CheckBox ID="ChkStatus" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
Here when i click save button i need check column wise data get the value in Telerik Radgrid how will do this
Jayesh Goyani
I have Telerik Radgrid following Fields
Name,Empno last field checkbox like this
<telerik:GridTemplateColumn HeaderText="Status">
<ItemTemplate>
<asp:CheckBox ID="ChkStatus" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
Here when i click save button i need check column wise data get the value in Telerik Radgrid how will do this