1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Data changes not represented in Custom Module

Data changes not represented in Custom Module

4 posts, 0 answered
  1. Ian Muir
    Ian Muir avatar
    13 posts
    Registered:
    26 Jan 2010
    26 Mar 2010
    Link to this post
    I've built a custom module using LINQ for data access. The database is being altered correctly, but the changes aren't being reflected in the UI.

    Is there some sort of caching going on? Is there a way to disable it?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    28 Mar 2010
    Link to this post
    Hello Ian Muir,

    I do not think that the problem is related to some caching. Most probably you are not getting or rebinding the data correctly. Below are links to two samples that you can observe

    New Year special - Integrate rating with Generic Content based modules
    Intra-Site Module with LINQ Provider

    All the best,
    Ivan Dimitrov
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
  3. Ian Muir
    Ian Muir avatar
    13 posts
    Registered:
    26 Jan 2010
    29 Mar 2010
    Link to this post
    I wouldn't think it's a databinding issue. We're using a RadGrid and calling the Databind method after the change in the db is made, but the Grid is still showing outdated information.

    Maybe I'm posting this in the wrong Telerik forum.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    29 Mar 2010
    Link to this post
    Hello Ian Muir,

    I created a sample module with RadGrid control that uses Linq - SQL to persist the data and I am not able to reproduce any problems related to items retrieving.

    protected void Page_Load(object sender, EventArgs e)
       {
           RadGrid1.InsertCommand += new Telerik.Web.UI.GridCommandEventHandler(RadGrid1_InsertCommand);
           RadGrid1.DeleteCommand += new Telerik.Web.UI.GridCommandEventHandler(RadGrid1_DeleteCommand);
           RadGrid1.ItemCreated += new GridItemEventHandler(RadGrid1_ItemCreated);
           RadGrid1.NeedDataSource += new Telerik.Web.UI.GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
       }
     
       void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
       {
              if (e.Item is GridEditableItem && (e.Item.IsInEditMode))
              {
                  GridEditableItem editableItem = (GridEditableItem)e.Item;
                  // do some other logic here
              }
       }
     
       void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
       {
           var dataSource = from c in DbContext.GridTables
                            select c;
           RadGrid1.DataSource = dataSource;
       }
     
       void RadGrid1_DeleteCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
       {
          
           var nameToDelete = (Guid)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["number"];
          var uNumber = DbContext.GridTables.Where(n => n.number == nameToDelete).FirstOrDefault();
          if (uNumber != null)
          {
              DbContext.GridTables.DeleteOnSubmit(uNumber);
              DbContext.SubmitChanges();
          }
       }
     
       void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
       {
           GridEditFormInsertItem editedItem = e.Item as GridEditFormInsertItem;
           var gridData = new GridTable();
           Hashtable values = new Hashtable();
           editedItem.ExtractValues(values);
           if (values["number"] !=null)
           {
               gridData.number = new  Guid(values["number"].ToString());
           }
           if (values["username"] != null)
           {
               gridData.username = (string)values["username"];
           }
           DbContext.GridTables.InsertOnSubmit(gridData);
           DbContext.SubmitChanges();
     
       }
     
       private TestGridDataContext _dataContext;
       protected TestGridDataContext DbContext
       {
           get
           {
               if (_dataContext == null)
               {
                   _dataContext = new TestGridDataContext();
               }
               return _dataContext;
           }
       }
       public override void Dispose()
       {
           if (_dataContext != null)
           {
               _dataContext.Dispose();
           }
           base.Dispose();
       }

    The RadGrid could be bound inside CreateChildControls() if you are inheriting from one of the base views for Generic Content based modules.

    Regards,
    Ivan Dimitrov
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
4 posts, 0 answered