GridDataItem - does not contain a definition

3 posts, 0 answers
  1. Austin
    Austin avatar
    2 posts
    Member since:
    Nov 2015

    Posted 24 Feb 2016 Link to this post

    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. Austin
    Austin avatar
    2 posts
    Member since:
    Nov 2015

    Posted 24 Feb 2016 in reply to Austin Link to this post

    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 


  3. Kostadin
    Kostadin avatar
    1733 posts

    Posted 29 Feb 2016 Link to this post

    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.

    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
Back to Top