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

RadGrid Unable to find the property on DataBinder.Eval(dataItem, "IsLocked")

4 Answers 321 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vishnu
Top achievements
Rank 1
Vishnu asked on 24 Jun 2014, 01:15 PM
I am having a issue trying to follow http://www.telerik.com/forums/breaking-change-hidden-column-cell-text-is-not-persisted-in-viewstate#0-UsFJGYDE6Wr8fRj8aMjA link. following method 2 but i need to implement the same OnItemDatabound.

private void ProcessGrid_OnItemDataBound(object sender, CommonGridEventArgs e)
{
if (e.ItemDataBound != null)
{
if (e.ItemDataBound.Item.ItemType == GridItemType.Item || e.ItemDataBound.Item.ItemType == GridItemType.AlternatingItem)
{

GridDataItem dataItem = (GridDataItem)e.ItemDataBound.Item;
 if (dataItem["IsLocked"] != null && Convert.ToBoolean(DataBinder.Eval(dataItem, "IsBoolFlagTrue"), CultureInfo.InvariantCulture))
 {
e.ItemDataBound.Item.Enabled = false;
}
}
}
}

Please help

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Jun 2014, 09:01 AM
Hi Vishnu,

Please correct your code as below:

C#:
if (dataItem["IsLocked"] != null && Convert.ToBoolean(DataBinder.Eval(dataItem.DataItem, "IsBoolFlagTrue"), CultureInfo.InvariantCulture))
{
//Your code
}

Thanks,
Shinu
0
Vishnu
Top achievements
Rank 1
answered on 25 Jun 2014, 09:38 AM
Thanks Shinu for your reply... i sorted it out ... but i have another problem
public IList<string> SelectedItemList
{
get
{
IList<string> ItemList = new List<string>();

foreach (GridDataItem dataItem in RadGrid.MasterTableView.Items)
{
if (IsGridItemSelected(dataItem))
{
 SelectedList.Add(dataItem["SelctionID"].Text);
}
}

return SeclectedIDList;
}
}

My code was working fine till we upgraded the telerik libraries & now dataItem["SelctionID"].Text derrived from RadGrid.MasterTableView.Items always returns null...
can you help
Thanks
Vish
0
Vishnu
Top achievements
Rank 1
answered on 25 Jun 2014, 09:41 AM

        public IList<string> SelectedItemIdList
        {
            get
            {
                IList<string> ItemIdList = new List<string>();                foreach (GridDataItem dataItem in ItemGrid.MasterTableView.Items)
                {
                    if (IsGridItemSelected(dataItem))
                    {
                        itemIdList.Add(dataItem["ItemID"].Text);
                    }
                }                return ItemIdList;
            }
        }
0
Shinu
Top achievements
Rank 2
answered on 26 Jun 2014, 04:02 AM
Hi Vishnu,

Its hard to identify the issue without your full code. Can you please make sure you have not set the Visible property of column to false? In case you want to hide a column set its Display property to false, then it can be accessed in the server side.

ASPX:
<telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" Display="false">
</telerik:GridBoundColumn>

Thanks,
Shinu
Tags
Grid
Asked by
Vishnu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Vishnu
Top achievements
Rank 1
Share this question
or