I am using GridClientSelectColumn for Selecting a row in a grid.i want to check whether the check box is checked or not in ServerSide.i have tried a lot but all in vain.
I am not using GridTemplateColumn since I have some restrictions for in my reqs.
Please give me some code snipets if possible
Please Help me .
Thanks,
A2H
13 Answers, 1 is accepted
You can check for whether the Selected property of GridDataItem is "True" or "False" instead of accessing the CheckBox control and checking the Checked property.
Feel free to share the comments,
Shinu.
Can u pls share some code snipets.I am pretty new to telerik controls.
Thanks
A2H
I hope the sample code shown below will help you to get started.
CS:
protected
void
Button1_Click(
object
sender, EventArgs e)
{
GridDataItem firstItem = (GridDataItem)RadGrid1.MasterTableView.Items[0];
// Get the first DataItem
if
(firstItem.Selected)
// Check for whether it is selected (checked) or not
{
Response.Write(
"Selected"
);
}
else
{
Response.Write(
"Not selected"
);
}
}
Also go through the following documentation:
Retrieving primary key field values for selected items
-Shinu.
That did the trick.Now I am able to get the value of Selected columns. Thanks a lot Shinu
Thanks,
A2H
If we have paging in gird and I have selected some rows in first paging and some rows in second rows,
At that time the above code is giving error.how can we incorporate paging also in this.
Thanks,
A2H
How to programatically uncheck the checkbox if the textbox value changes? I have used the code from this example but it only works once.
What is the correct way to reference the checkbox checked property. I do not want to loop through every row, just find the checkbox.checked for the row that has had the textbox edited.
protected void AmountApproved_TextChanged(object sender, EventArgs e)
{
GridDataItem firstItem = (GridDataItem)gridFundingBills.MasterTableView.Items[0]; // Get the first DataItem
if (firstItem.Selected) // Check for whether it is selected (checked) or not
{
firstItem.Selected = false;
}
else
{
Response.Write("Not selected");
}
UpdateBalances();
}
You can get a reference to the row using (sender as TextBox).NamingContainer as GridDataItem.
Then, you can toggle the selection of the item depending on your custom condition or find any given template control using the FindControl method.
Hope this helps. You can also achieve that on client-side.
Regards,
Eyup
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
<telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" HeaderStyle-Width="50px" ItemStyle-Width="50px">
</telerik:GridClientSelectColumn>
protected void AmountApproved_TextChanged(object sender, EventArgs e)
{
//Some text has changed, now I want to see if the ClientSelectColumn checkbox is checked
//what is the syntax?
if (thereIsAColumnWithAuniqueNameOfClientSelectColumn.checked == true)
{
thereIsAColumnWithAuniqueNameOfClientSelectColumn.checked = false;
}
}
The correct way for handling this would be to get reference to the parent GridDataItem (using the NamingContainer property of your TextBox control) and check its Selected property. If it is set to true, this
will mean that the item is selected.
Generally, as the name clearly stated, this is a GridClientSelectColumn and you should not use that column for retrieving the selected state of an item.
You can take a look at the following help article for accessing controls in RadGrid:
Regards,
Konstantin Dikov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Hi,
I am using a GridClientSelectColumn and have a paging on my grid. I need following things on my grid.
1) Multiple selection client-side
2) If do select all from the header checkbox on page1, it should also select the rows at all other pages.
3) Deselect should deselect only the single row, not all.
4) If select a single row on and move on to any other page and now when come back to page1 the row should persist its state.
I would appreciate any help on this.
Thanks,
Rahul
You can use the following approach to preserve selection through pages:
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/Selecting/persisting-selected-rows-client-side
You can examine the RadGridGetAllSelectedItemsImproved.zip web site sample provided in the last post here for a practical implementation:
http://www.telerik.com/support/code-library/get-selected-items-through-all-pages#1eTU8nr-GUG8zfGgOGbIcA
I hope this will prove helpful.
Regards,
Eyup
Progress Telerik
Thanks, Sir. It's Working.
Also i get stuck in telerik Rad Popup: After closing popup page parent page gets scrolled automatically.
You can check the suggestions and samples provided in the following post to resolve this issue:
https://www.telerik.com/forums/radgrid-jumps-to-first-line-when-selecting-row#oMKrk-s78UiZ5ik2B22pow
Regards,
Eyup
Progress Telerik