Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to persist Asp Net GridView data (coming from SignalR) after page postback?
    primarykey
    data
    text
    <p>I create module in DotNetNuke CMS. Ihave no need to edit my data, just display with sorting and paging. There is asp:GridView control which has DataTable as data source. In Page_Load event some rows with data are added to dataTable and properly displayed. Sorting and pagging work ok too. To maintain data in GridView (and for sorting purposes) used ViewState. I choosed using of ViewState to not overload the server, incoming data doesn't have to be secure. For incoming data I use SignalR, so javascript function receives data from server(hub). Figured out that I will call from javascript web method(C#) AddNewRowToDataTable (DateTime time, string name, double value...) passing parameters to the method. Unfortunatelly web method must be static and this is the reason why ViewState can not be used in it. So if I can't use ViewState when adding new row I lose all data. This doesn't help:</p> <pre><code>[WebMethod] public static void AddNewRowToDataTable(DateTime time, string name, double value) { Page page = HttpContext.Current.Handler as Page; if (page != null) { if (page.ViewState["dtValues"] != null) { // Get the DataTable from ViewState and inserting new data to it. DataTable dtValues = (DataTable)page.ViewState["dtValues"]; // Add the new row. dtValues.Rows.Add(new object[] { time, name, value }); // Rebind the GridView control to show inserted data. BindGridView(); } } } </code></pre> <blockquote> <p>Error Cannot access protected member 'System.Web.UI.Control.ViewState' via a qualifier of type 'System.Web.UI.Page'; the qualifier must be of type 'Christoc.Modules.DNNSignalR.View' (or derived from it)</p> </blockquote> <p>I preferr not to use Session for maintaing data because don't want to heavy load on server side.</p> <p>What would be the best approach to my requirements: In Asp Net, DotNetNuke module, display data coming from SignalR with sorting and paging functionality, not losing data on postbacks?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload