Search code examples
c#asp.netascx

How do I refresh a web controler inside a gridview ASP.NET


How can I refresh a web controller inside a gridview? I have a web controller inside a gridview as you can see here:

<asp:TemplateField>
    <ItemTemplate>
        <tr>
            <td colspan="100%" style="background: #F5F5F5">
                <div id="div<%# Eval("contrato_id") %>" style="overflow: auto; display: none; position: relative; left: 15px; overflow: auto">
                    <div class="ExpandTableHeader">
                    </div>
                    <div class="body">
                        <div id="tabs-ComponentesSection" class="menusection">
                            <TWebControl5:WebControl5 ID="Header8" runat="server" />
                        </div>
    </ItemTemplate>
</asp:TemplateField>

I want to refresh the following controller.

<TWebControl5:WebControl5 ID="Header8" runat="server" />

On the following button click.

<asp:Button class="btn btn-primary" ID="btnChooseContract" runat="server" Text="Elegir contrato" OnClick="AddContractToQuote" />

Here is the code behind of the button.

protected void AddContractToQuote(object sender, EventArgs e)
{
}

Solution

  • Used some code that looks like this YEARS ago...

    for (int x = 0; x < GridViewName.Rows.Count; x++)
    {
        GridViewRow row = (GridViewRow) GridViewName.Rows[x];
    
        Control contr = (control) row.Cells[1].FindControl("NameOfYourControl");
    
        contr = //Another similar control that looks like the first, but different
    
    }