1

I have an ASPxGridView and 2 radio buttons on my project. When I change selection of the radio button group, it changes the select command of the data source. After that, when I clicked on 2nd page, the data source's select command changes into previous situation.

Here is the example.. http://www.2shared.com/file/HwnBYcFS/WebApplication8.html

Note: When the page loads data source filters 'Neo's, click on the "All" radio button, and change the page.

Thanks for answers..

Filip
  • 3,257
  • 2
  • 22
  • 38
Erdinç Özdemir
  • 1,363
  • 4
  • 24
  • 52
  • Prehaps it is not stored in the Viewstate? Or is it excuting a piece code to return it to the previous situation? – Ruben Dec 28 '11 at 12:03
  • It should not execute, but I didn't understand is it executing. Did you try the example? – Erdinç Özdemir Dec 28 '11 at 12:10
  • No i can't try it on this pc. Have you tried looking if it is saved in viewstate? – Ruben Dec 28 '11 at 12:16
  • I have no idea how to do it. Can you explain it for me? – Erdinç Özdemir Dec 28 '11 at 12:21
  • btw the 2 radio buttons you use are those devexpress controls aswell? – Ruben Dec 28 '11 at 12:29
  • yes, they are ASPxRadioButton. – Erdinç Özdemir Dec 28 '11 at 12:31
  • EnableViewState properties is True then i suppose? And AutoPostBack False? And does anything change if you put AutoPostBack on True? – Ruben Dec 28 '11 at 12:35
  • EnableViewState property is True and I change AutoPostBack but nothing changed. – Erdinç Özdemir Dec 28 '11 at 12:38
  • What about manualy saving the datasource in viewstate and on the load event of the datasource set the value to the value of the datasource in the viewstate? In the gridview if you got back to the first page is the same radio button stil selected or does that reset aswell? – Ruben Dec 28 '11 at 12:52
  • Ah good ^^ You should answer your own qeustion with the sulotion so other people can solved this problem if they have the same problem and then you can except your own answer as answer so everyone can see it is already solved. – Ruben Dec 28 '11 at 13:45

1 Answers1

2

1.add init event handler to grid
2.implement init event handler

protected void Grid_Init(object sender, EventArgs e)
{
    if (!IsCallback)
        Page.Session["selectCommand"] = null;

    if (Page.Session["selectCommand"] != null)
        AccessDataSource1.SelectCommand = (string)Page.Session["selectCommand"];
    grid.DataBind();
}

3.Change custom callback handler

protected void grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
{
    if (e.Parameters == "Neo")
    {
        AccessDataSource1.SelectCommand = "select Name,Surname from Person where Name='Neo'";
    }
    else if (e.Parameters == "All")
    {
        AccessDataSource1.SelectCommand = "select Name, Surname from Person";
    }
    Page.Session["selectCommand"] = AccessDataSource1.SelectCommand;
    grid.DataBind();
}

4.use CheckedChange client side event instead of gotfocus

<ClientSideEvents CheckedChanged="
    function(s, e)         
    {
        if(s.GetValue())
            grid.PerformCallback(&quot;Neo&quot;);
    }" />
Filip
  • 3,257
  • 2
  • 22
  • 38