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

GridDataItem - does not contain a definition

2 Answers 739 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Austin
Top achievements
Rank 1
Austin asked on 24 Feb 2016, 06:28 PM

I am trying to pull grid column data in order to call a procedure.  on e.item, bold below, i am receiving error :

Error1'Telerik.Web.UI.GridNeedDataSourceEventArgs' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'Telerik.Web.UI.GridNeedDataSourceEventArgs' could be found (are you missing a using directive or an assembly reference?)

here is the C#

protected void Mask_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            GridDataItem dataItem = e.Item as GridDataItem;
            string @Empl_ID = dataItem.GetDataKeyValue("Empl_ID").ToString();
            RadGridEmpl.DataSource = DataLayer.FirmEmployees.PhoneMask(@Empl_ID);
        }

how can this be fixed?

2 Answers, 1 is accepted

Sort by
0
Austin
Top achievements
Rank 1
answered on 24 Feb 2016, 06:53 PM

i figured out it needed to be GridItemEventArgs not GridNeedDataSourceEventArgs.

on to the real issue on a masked column can you make it dynamic?  i have a data source that will change the mask 

 

0
Kostadin
Telerik team
answered on 29 Feb 2016, 11:03 AM
Hello Austin,

A possible solution is to access the MaskTextBox on ItemCreated event handler and change the Mask and DisplayMask properties. Please check out the following code snippet.
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem editItem = e.Item as GridEditableItem;
        RadMaskedTextBox mask = editItem["MaskedColumn"].Controls[0] as RadMaskedTextBox;
        mask.DisplayMask = "(###-###-####)";
        mask.Mask = "(###-###-####)";
    }
}

More about accessing cells and their controls could be found in the following help article.

Regards,
Kostadin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Austin
Top achievements
Rank 1
Answers by
Austin
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or