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

[Solved] LinkButton in RadGrid "ExpandCollapse" column causes full postback

2 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Katie Arnott
Top achievements
Rank 1
Katie Arnott asked on 15 Apr 2013, 04:46 PM
When adding a LinkButton to a GridDataItem in an ajaxified RadGrid, it causes a full postback.  I do not want a full postback. 
This is my code:

private
void GridItem_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (e.Item as GridDataItem);
                 
 
                    //cannot .Clear() expand/collapse item
                    item["ExpandColumn"].Controls[0].Visible = false;
 
                    LinkButton expand = CreateLinkButton();
                    expand.CommandArgument = _expandText;
                    expand.ID = _btnExpand;
                    item["ExpandColumn"].Controls.Add(expand);
                     
                    LinkButton collapse = CreateLinkButton();
                    collapse.CommandArgument = _collapseText;
                    collapse.ID = _btnCollapse;               
                    item["ExpandColumn"].Controls.Add(collapse);
 
                    //hide collapse on load
                    item["ExpandColumn"].Controls[2].Visible = false;
 
                    foreach (Control control in item["ExpandColumn"].Controls)
                    {
                        RadAjaxManager RadAjaxManager1 =                RadAjaxManager.GetCurrent((System.Web.UI.Page)System.Web.HttpContext.Current.Handler);
                        RadAjaxManager1.AjaxSettings.AddAjaxSetting(control, (sender as RadGrid));
                    }
                }
}

I've even tried the below on RadGrid_PreRender with no luck

private void RadGrid_PreRender(object sender, EventArgs e)
        {
            RadAjaxManager RadAjaxManager1 = RadAjaxManager.GetCurrent((System.Web.UI.Page)System.Web.HttpContext.Current.Handler);
            RadAjaxManager1.AjaxSettings.AddAjaxSetting((Control)sender, (Control)sender);
           RadAjaxManager1.EnableAJAX = true;
        }

2 Answers, 1 is accepted

Sort by
0
Accepted
Elliott
Top achievements
Rank 2
answered on 15 Apr 2013, 07:05 PM
hi Katie
are you creating a RadButton - or a Microsoft LinkButton?

I'd create a RadButton as a link button and see about cancelling the Click event

Marianne
0
Katie Arnott
Top achievements
Rank 1
answered on 15 Apr 2013, 07:39 PM
Thank you so much Marianne.

I updated the LinkButton to use RadButton and that fixed the issue.  I still wanted to use the _ItemCommand EventHandler so I didn't want to cancel the OnClick event, but I didn't have to :)    
Tags
Grid
Asked by
Katie Arnott
Top achievements
Rank 1
Answers by
Elliott
Top achievements
Rank 2
Katie Arnott
Top achievements
Rank 1
Share this question
or