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

Problem with different RebindReason

3 Answers 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 24 Oct 2012, 04:06 PM
Hi, 

I have 2 grids on the web page, which I put into RadAjaxManager

<telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" >
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGridResults">
            <UpdatedControls>  
                <telerik:AjaxUpdatedControl ControlID="RadGridResults" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="RadGridResultsTest">
            <UpdatedControls>  
                <telerik:AjaxUpdatedControl ControlID="RadGridResultsTest" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>


Both of them have detail tables and I obtain data through NeedDataSource with similar content =>

if (e.IsFromDetailTable || e.RebindReason == GridRebindReason.InitialLoad)
  return;
  
RadGridResultsTest.DataSource = GetMainData();

First grid works fine and when I try to go to next page or change pagesize everything works correctly because all the time I obtain GridRebindReason.PostBackEvent in NeedDataSource method.

On the other hand second grid will display data only after button click, because there is GridRebindReason.ExplicitRebind
but during paging I obtain all the time GridRebindReason.InitialLoad, which makes my grid disappear. I also tried to remove condition

e.RebindReason == GridRebindReason.InitialLoad

so paging was suddenly working. I had 3 pages with 26 rows. I changed pagesize to 15 so I had 2 pages. But when I clicked on second page, grid somehow restored to pagesize 10 and got itself to first page.

Do you have any idea, where can be the problem and how can I make this work ?

Thanks a lot.

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 24 Oct 2012, 07:04 PM
Hello,

public bool WillBindGrid
{
    get
    {
        if (ViewState["WillBindGrid"] == null)
            return false;
        return (bool)ViewState["WillSucceed"];
    }
    set
    {
        ViewState["WillBindGrid"] = value;
    }
}

Protected void Button2_Click(Object sender,
                           EventArgs e)
    {
       WillGridBind = true;
      RadGridResultsTest.Rebind(); // Your Second grid
    }

protected void RadGridResultsTest_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
 ifWillGridBind == true)
{
            RadGridResultsTest.DataSource = "YourDataSourceComesHere";

        }


Thanks,
Jayesh Goyani
0
Peter
Top achievements
Rank 1
answered on 25 Oct 2012, 10:45 AM
Thanks for the suggestion... I changed that but I still have problem with that PageSize, that when I change the value to 15, it reloads the data, but after I go to next page, PageSize value is somehow restored to 10 ? Did I set it manually in the event or grid is taking care about it ?

I also tried to change the data obtaining =>

RadGridResultsTest.DataSource = GetMainData();

when I was obtaining data from local MS SQL Server, everything worked ok with RebindReason I described earlier and also PageSize was remembered correctly...

But when I changed obtaining data by using our project classes, where are private variables, connecting to outside databases and a lot of messy stuff, then grid behaviour become weird... 

I was thinking that it doesn't matter what is the content of GetMainData() as far as it returns DataTable... Appearently somehow content of that method influence grid behaviour despite the fact, that I am not working with grid inside that method... 

Do you have any idea what I should focus on or what I should avoid ?

Thanks
0
Peter
Top achievements
Rank 1
answered on 25 Oct 2012, 02:15 PM
Well, after several hours of debugging I found the culprit... 

I use in that method something like this

newBkSegmentsList = new Dictionary<string, List<SegmentSetMemb>>();
newBkSegmentsList.Add("123", new List<SegmentSetMemb>());

while 

private Dictionary<String, List<SegmentSetMemb>> newBkSegmentsList {
  get {
    return (ViewState["newBkSegmentsList"] == null ? null : (Dictionary<String, List<SegmentSetMemb>>)ViewState["newBkSegmentsList"]);
  }
  set {
    ViewState["newBkSegmentsList"] = value;
  }
}

SegmentSetMemb has several parents and it has plenty of methods inside... I don't know why it cause
the problem... Did it help you somehow ?

Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Peter
Top achievements
Rank 1
Share this question
or