Search code examples
c#asp.netcheckboxtelerik-gridautopostback

LinkButton Gets Hidden on AutoPostBack of SelectAll/Header CheckBox


I have a telerik:radgrid which has a checkbox and a linkbutton for each row and a check box in the header - to select all the checkboxes of the rows.

I am adding some dynamic text to the linkbutton from code behind using HtmlGenericControl

Like

status.Controls.Add(html_controller);

Where status is my linkbutton

Now the problem is that whenever I click on the header check box a postback occurs and my linkbutton along with the html_controller gets hidden. What changes should I do to fix it?

Below are the Header Checkbox and LinkButton

Header Check Box -

<asp:CheckBox id="headerChkbox" OnCheckedChanged="ToggleSelectedState" AutoPostBack="True" runat="server"></asp:CheckBox>

LinkButton -

<asp:LinkButton ID="status"  runat="server" CommandName="Status" CausesValidation="false" style="text-align:center;cursor:pointer;" OnClientClick="return VerifyComments(this);"/>

Solution

  • I solved the problem by using a asp:Label(with runat='server') within my asp:LinkButton instead of adding a HtmlGenericControl from code behind and assigned the dynamic text to Text field of the asp:Label (labelname.Text="")

    The issue was apparently because of the postback issue with the LinkButton which got solved when I made use of asp:Label with runat='server'.