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

Error saving persisted user settings to SQL field

7 Answers 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 2
David asked on 28 Jul 2010, 05:06 PM

I am tring to save the user data for persisting grid settings to a sql database, using the exact code from the demo site.

protected void btnSaveSettings_Click(object sender, EventArgs e)
    {
        string user = UserSelection.SelectedValue;
        GridSettingsPersister SavePersister = new GridSettingsPersister(RadGrid1);
        Session[user] = SavePersister.SaveSettings();
        InfoImage.Visible = true;
        StatusLabel.Text = "Settings for " + user + " saved successfully!";
        btnLoadSettings.Enabled = true;
    }

 

SavePersister.SaveSettings() is of type String, so I don;t know what the problem is.

However, when I try to save the string into a sql varchar(max) field, it fails. Or rather, LoadSettings(string value) is failing.

Is anyone else having this problem? Is there example code of saving the settings to a DB?

BONUS QUESTION: I need to add a RESET button. Can you pass String.Empty into loadsettings?

7 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 03 Aug 2010, 07:37 AM
Hi David,

Could you give more details on what exactly "failing" means in your case (what exception do you get)? Could you also provide your aspx and code-behind?

Thank you.

Regards,
Tsvetoslav
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
0
Rob
Top achievements
Rank 1
answered on 11 Aug 2010, 02:57 PM
BONUS QUESTION: I need to add a RESET button. Can you pass String.Empty into loadsettings?

Passing String.Empty doesn't work. Is there a proper way to do it?
0
Tsvetoslav
Telerik team
answered on 13 Aug 2010, 07:57 AM
Hello Rob,

I do not know how your LoadSettings methods is implemented but if it follows the guidelines in our help documentation and the related online example - indeed, passing an empty string to it won't do as the LosFormatter will fail when trying to desirialize an empty string. The correct and easiest approach is not to call the LoadSettings method whem you have an empty string for the persisted settings or you just don't want any persisted settings to be loaded.

Hope it helps.

All the best,
Tsvetoslav
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
0
Rob
Top achievements
Rank 1
answered on 13 Aug 2010, 08:54 AM
Hi Tsvetoslav

My implementation follows exactly the guidelines. But I'm not talking about the OnLoad Event (or similar).

How would you implement a button to reset the settings (without the reload the whole page)? E.g in a situation like
protected void RadToolBarOption_ButtonClick(object sender, RadToolBarEventArgs e)
    {
      RadToolBarButton btn = e.Item as RadToolBarButton;
      switch(btn.Value)
      {
         case "RESET":
           ---> how reset setting here <---
           RadGridDummy.Rebind();
           break;
      }
}

Regards
Rob
0
Veli
Telerik team
answered on 19 Aug 2010, 07:36 AM
Hi Rob,

To "reset" the grid to its original state, you need to have just another setting that defines the original state. You then just load these settings when you need to reset the grid.

Regards,
Veli
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
0
David
Top achievements
Rank 2
answered on 19 Aug 2010, 03:13 PM
That is not practical for a Grid that has dynamically added columns.

Not better suggestions?
0
Veli
Telerik team
answered on 19 Aug 2010, 05:11 PM
Hi David,

Then you can clear RadGrid's applied settings manually:

1. Reset the PageSize to 10 (or any predefined value you choose)
2. Clear the RadGrid.MasterTableView.SortExpressions collection
3. Clear the RadGrid.MasterTableView.FilterExpression string
4. Clear the RadGrid.MasterTableView.GroupByExpressions collection
5. For each dynamic GridColumn in your grid:
    5.1. Clear the Width (or set it to some predefined default value for that column)
    5.2. Set Display = true (unless the column is hidden by default)
    5.3. Set Visible = true (unless the column is hidden by default)
    5.4. Set GridColumn.CurrentFilterFunction = GridKnownFunctions.NoFilter;
    5.5. Set GridColumn.CurrentFilteValue = String.Empty;
    5.6. Reset the OrderIndex (set the OrderIndex to the index of the column in the RadGrid.MasterTableView.Columns collection


Veli
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
Tags
Grid
Asked by
David
Top achievements
Rank 2
Answers by
Tsvetoslav
Telerik team
Rob
Top achievements
Rank 1
Veli
Telerik team
David
Top achievements
Rank 2
Share this question
or