I am working on the Telerik Grid, my first column in that grid is "GridClientSelectColumn", with which I am able to 'check' the required row and save to the database, but I could not bind the saved items to that "GridClientSelectColumn". Below is the sample code which I am using.
1. In Aspx Page
<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="true"
AllowAutomaticUpdates="True" PageSize="10" Width="100%" AutoGenerateColumns="false"
AllowMultiRowSelection="true" DataSourceID="sds_Reconcile" onitemcreated="RadGrid1_ItemCreated"
OnItemDataBound="RadGrid1_ItemDataBound" OnPreRender="RadGrid1_PreRender">
<PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true" />
<MasterTableView Name="Table1" DataKeyNames="id" AllowMultiColumnSorting="True" AllowFilteringByColumn="true" TableLayout="Fixed" EditMode="InPlace" CanRetrieveAllData="False">
<HeaderStyle CssClass="Level1HeaderStyle" />
<Columns>
<telerik:GridClientSelectColumn DataTextField="pvkey" Text="select" UniqueName="column1"
HeaderText="Select"> </telerik:GridClientSelectColumn>
...
</Columns>
2. C# Code
a. In ItemDataBound and ItemCreated i have used this code
if (e.Item is GridDataItem) {
GridDataItem item = (GridDataItem)e.Item;
if (item.OwnerTableView.Name == "Table") {
if (item["is_recon"].Text == "True") {
CheckBox chkbx = (CheckBox)item["column1"].Controls[0];
chkbx.Checked =
true;
e.Item.BackColor = System.Drawing.
ColorTranslator.FromHtml("green"); }}}
b. In PreRender, I am using this code
foreach
(GridDataItem dataItem in this.RadGrid1.MasterTableView.Items)
{
if (dataItem["is_recon"].Text == "True")
{
CheckBox chkbx = (CheckBox)dataItem["column1"].Controls[0];
chkbx.Checked =
true;
}
dataItem["column1"].BackColor = System.Drawing.Color.Gray;
}
I am able to get the correct values from the database, and they are executing with the chkbx.Checked = true. But I could not see the items checked in the webpage when they are loaded.
And also I am using Default skin, and assigning my custom css to that Grid, with which I am unable to color the row. (dataItem["column1"].BackColor = System.Drawing.Color.Gray;)
Thanks
Mark