Partial Postback via HTML Radio Button in Gridview

I'm creating HTML radiobuttons in GridView dynamically on GridView's RowCreated events as below:
if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Literal output = (Literal)e.Row.FindControl("plcholdRadioButton");
                output.Text = string.Format(
                    @"<input type=""radio"" name=""ContactGroup"" " +
                    @"id=""RowSelector{0} "" onClick=""AJAXPostback('RowSelector{0}');"" value=""{0}""", e.Row.RowIndex);
                if (MainContactSelectedIndex == e.Row.RowIndex)
                {
                    output.Text += @" checked=""checked""";
                    ViewState["MainClientId"] = DataBinder.Eval(e.Row.DataItem, "clid");
                }
                output.Text += " />";
            }

GridView is in UpdatePanel which is hosted in Master Page, when click one of this radio buttons in gridview it fires up the following javascript:

function AJAXPostback(element)
{
    var grgDynControl = document.getElementById('element');
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm._doPostBack('grgDynControl','');
}

These all works fine but it does full page postback instead of partial postback. How can i achieve the partial postback with this system?
LVL 3
vs_mkazanovaAsked:
Who is Participating?
 
aibusinesssolutionsCommented:
ah, ok.  That's the problem, having the update panel on the masterpage.  If you view the source the lnkButton probably has an ID of something like ctl00_ContentPlaceHolder1_lnkButton

If so then you'll need to do __doPostBack('ctl00$ContentPlaceHolder1$lnkButton','')

Either that, or you can place the lnkButton on the master page, inside of the update panel, but outside of the contentplaceholder.
0
 
aibusinesssolutionsCommented:
Since the radio buttons are just plain HTML radio buttons, I would put a linkbutton in the update panel called "lnkUpdate", and then in the onClick event for the radio buttons, just put __doPostBack('lnkUpdate','')

If you have childrenastriggers set to true, it will do a partial postback, if not just add a trigger for lnkUpdate

0
 
vs_mkazanovaAuthor Commented:
Can you post code for this?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
aibusinesssolutionsCommented:
if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Literal output = (Literal)e.Row.FindControl("plcholdRadioButton");
                output.Text = string.Format(
                    @"<input type=""radio"" name=""ContactGroup"" " +
                    @"id=""RowSelector{0} "" onClick=""__doPostBack('lnkButton','');"" value=""{0}""", e.Row.RowIndex);
                if (MainContactSelectedIndex == e.Row.RowIndex)
                {
                    output.Text += @" checked=""checked""";
                    ViewState["MainClientId"] = DataBinder.Eval(e.Row.DataItem, "clid");
                }
                output.Text += " />";
            }


Then in your UpdatePanel, add a LinkButton
<asp:LinkButton ID="btnFinished" runat="server" Text="Finished" style="display:none" />  

And if you need a trigger:
<Triggers>
     <asp:AsyncPostBackTrigger ControlID="btnFinished" EventName="Click" />        
</Triggers>
0
 
aibusinesssolutionsCommented:
Sorry, that should be lnkButton, not btnFinished.

Then in your UpdatePanel, add a LinkButton
<asp:LinkButton ID="lnkButton" runat="server" Text="Update" style="display:none" />  

And if you need a trigger:
<Triggers>
     <asp:AsyncPostBackTrigger ControlID="lnkButton" EventName="Click" />        
</Triggers>
0
 
vs_mkazanovaAuthor Commented:
I've tested but page still flickers, and progress bar on the browser shows up on the bottom.
0
 
aibusinesssolutionsCommented:
Is the page live so I can see it?  Or can you post some code?

I just tested this and it is working fine.  The button does an async postback whether it's inside the updatepanel or outside, since the trigger is defined.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:LinkButton ID="btnFinished" runat="server" Text="Finished" Style="display: none;" />        
        <input type="button" value="button" onclick="__doPostBack('btnFinished','')" />
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnFinished" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>
 
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFinished.Click
    Label1.Text = Now.ToLongTimeString
End Sub

Open in new window

0
 
vs_mkazanovaAuthor Commented:
no it's on intranet,
master page holds the update panel which i have contentplaceholder inside
and content page has the gridview that hosts the gridview with radiobuttons.
0
 
vs_mkazanovaAuthor Commented:
That was it, as soon as i placed ctl00$lnkButton in doPostBack, it put me back into business.
Thank you for yor help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.