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

Grid rebind from RadButton outside grid

9 Answers 128 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Philip Senechal
Top achievements
Rank 1
Philip Senechal asked on 23 Dec 2010, 12:16 AM
grrr...I had this working at one point and now I can't seem to figure out what's going on.

I have a page in Sitefinity 4.0 (was in 3.7) with a user control with a RadGrid in edit mode with a single record...basically I'm using it as an input form.

I'm putting the grid into edit mode in my Page_Load event using the following...
protected void Page_Load(object sender, EventArgs e)
{
    // Put the grids into edit mode on the selected request
    for (int i = 0; i < RadGrid1.PageSize; i++)
    {
        RadGrid1.EditIndexes.Add(i);
    }
}

I have a RadButton declared outside the grid as follows...
<telerik:RadButton ID="RadButton1" Skin="Default" Text="Save" Font-Underline="false"
    OnClick="RadButton1_Click" AutoPostBack="true" UseSubmitBehavior="false" runat="server" />

and the Ajax settings for this page as follows:
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadButton1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Skin="Default" runat="server" />

and here is the button click event...
protected void RadButton1_Click(object sender, EventArgs e)
{
    EISDataContext db = new EISDataContext();
 
    // Get access to the grid edit item
    GridItem[] items1 = RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem);
     
    for (int i = 0; i < items1.Length; i++)
    {
        GridEditableItem item = (GridEditableItem)items1[i];
 
        // LINQ code to update database...
    }
 
    // Reset the edit index and rebind the grid
    RadGrid1.EditIndexes.Clear();
    RadGrid1.EditIndexes.Add(0);
    RadGrid1.Rebind();
}

The update code works great and the database is updated with the new values when I click the RadButton, and I see the ajax image over the grid, but the values don't update on the grid unless I do a complete page refresh or press the RadButton again. The funny thing is if I keep pressing the RadButton, the values change back and forth from the old values to the new values.

Can you see what I'm missing? Could it be something in the change to Sitefinity 4.0 that's handling ajax requests differently that's causing the issue? Thanks.

9 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 27 Dec 2010, 04:03 PM
Hello Philip,

Could you please try modifying the ajax settings as below and let me know if it makes any difference:

<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadButton1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                <telerik:AjaxUpdatedControl ControlID="RadButton1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>


All the best,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Philip Senechal
Top achievements
Rank 1
answered on 27 Dec 2010, 07:19 PM
Hi Iana,

Thank you for the reply. I did what you suggested and added the RadButton as an updated control to the RadButton AJAX setting and that did not change the behavior at all. To make sure it wasn't the AJAX settings, I actually removed the entire RadAjaxManagerProxy section so that the page would do a post back and the same behavior is present as in my original post.

Here are the Page_Load and NeedDataSource events if this helps at all...
protected void Page_Load(object sender, EventArgs e)
{
    // Put the grids into edit mode on the selected request
    for (int i = 0; i < RadGrid1.PageSize; i++)
    {
        RadGrid1.EditIndexes.Add(i);
    }
}
 
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    // Populate the left side of the Request screen
    EISDataContext db = new EISDataContext();
    var q_request = from request in db.tRequests
                    where request.ReqID == 1
                    select request;
 
    RadGrid1.DataSource = q_request;
}

There's really not a whole lot to them. I also tried substituting a regular ASP button instead of the RadButton and the exact same behavior is present which is making me think it's something with the Grid.

Any other ideas? Thanks for the assistance!
0
Iana Tsolova
Telerik team
answered on 28 Dec 2010, 02:54 PM
Hello Philip,

Can you make sure the grid and the page ViewState is enabled in this case?

All the best,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Philip Senechal
Top achievements
Rank 1
answered on 28 Dec 2010, 11:35 PM
Hi Iana,

Thanks for the reply. I enabled the ViewState in 3 separate places to ensure it's on

web.config
Page_Load event
RadGrid declaration

This didn't change anything at all. I suppose I could attempt to pull this page out of Sitefinity to see if I can isolate that as a contributing factor. I will attempt to get to that tomorrow, but would appreciate any further suggestions you might have. Thanks.
0
Iana Tsolova
Telerik team
answered on 30 Dec 2010, 11:57 AM
Hi Philip,

Indeed, we have seen the described behavior is Sitefinity pages with disabled ViewState. That is why I suggested you to enable and see how it goes. As this did not make any difference, isolating the problematic page out of Sitefinity should help us find where the source of the problem in your case is.

Best wishes,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Ken
Top achievements
Rank 1
answered on 04 Jan 2011, 12:26 AM
I'm actually having a similar problem in that i have a radbutton outside a radgrid.  The point of this button is to take the value of a numerictextbox and pass that value to a datasource.  Afterwords I have radgrid1.rebind().  This should refresh the page with the row on the grid that had the same PID as the textbox value removed from the grid.  Everything works fine but the grid does not refresh.  I have to refresh the whole page to have the desired effect take place.  I have drag and drop rows on the grid and the same radgrid1.rebind() works perfectly for that.  I'm using 2010 q3 in VS 2010 with asp 4.0 in VB.net.  Any help would be very appreciated.
0
Iana Tsolova
Telerik team
answered on 05 Jan 2011, 09:20 AM
Hello Ken,

Is the problematic page ajaxified? And do you have a setting where the RadButton updates the RadGrid? If so, try adding the RadButton in the UpdatedControls collection of the same as well and see if the issue persists.

Best wishes,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Rick
Top achievements
Rank 1
answered on 18 Nov 2013, 10:32 PM
I have the same issue, Is this resolved for anybody, please let me know the work around?

<telerik:AjaxSetting AjaxControlID="RadbtnEditAll">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGridStores" LoadingPanelID="RadAjaxLoadingPanel1">
                    </telerik:AjaxUpdatedControl>                    
                    <telerik:AjaxUpdatedControl ControlID="btnEditAll"></telerik:AjaxUpdatedControl>
                    
                </UpdatedControls>
            </telerik:AjaxSetting>


thanks
0
Maria Ilieva
Telerik team
answered on 21 Nov 2013, 11:49 AM
Hi Rick,

Could I kindly ask you to brief the exact issue you are currently facing as this thread is rather old and most of the similar issues are already properly working int he new versions of the controls?

Regards,
Maria Ilieva
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Philip Senechal
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Philip Senechal
Top achievements
Rank 1
Ken
Top achievements
Rank 1
Rick
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or