How can I force Gridview RowDataBound event to fire in update panel?

How can I force Gridview RowCreated event to fire in update panel? I have this code firng on other gridviews not in an update panle. I also tried using the RowCreated event, but I lose all of my style associated with the grid.

Any ideas on how to make this code work?
<asp:UpdatePanel ID="Upl1" runat="server">
                <ContentTemplate>
                    <asp:GridView ID="gvSearchResults" runat="server" DataKeyNames="iEmployeeID" HeaderStyle-ForeColor="White"
                        AllowSorting="true" OnSorting="gvSearchResults_Sorting" AllowPaging="true" PageSize="10"
                        OnPageIndexChanging="gvSearchResults_PageIndexChanging" Width="100%" AutoGenerateColumns="false"
                        CssClass="myGrid">
                        <EmptyDataTemplate>
                            No data to display.
                        </EmptyDataTemplate>
                        <HeaderStyle CssClass="myGridHeader"></HeaderStyle>
                        <AlternatingRowStyle CssClass="myGridAltItem" />
                        <RowStyle CssClass="myGridItem" />
                        <Columns>
                            <%--<asp:BoundField DataField="report_id" HeaderText="Report Id" ReadOnly="True" SortExpression="report_id" />--%>
                            <asp:BoundField DataField="vcCompletedFormFilling" HeaderText="Completed By" ReadOnly="True"
                                SortExpression="vcCompletedFormFilling" />
                            <asp:BoundField DataField="vcNameFormFilling" HeaderText="Submitted By" ReadOnly="True"
                                SortExpression="vcNameFormFilling" />
                            <asp:BoundField DataField="vcName" HeaderText="Emp Name" ReadOnly="True" SortExpression="vcName" />
                            <asp:BoundField DataField="vcSupervisor" HeaderText="Supervisor" ReadOnly="true"
                                SortExpression="vcSupervisor" />
                            <asp:BoundField DataField="Request_Type" HeaderText="Request Type" ReadOnly="true"
                                SortExpression="Request_Type" />
                            <asp:BoundField DataField="dtupdTime" HeaderText="Date Processed" DataFormatString="{0:g}"
                                ReadOnly="True" SortExpression="dtupdTime" HtmlEncode="false" />
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <input type="button" value="View Details " onclick="viewDetails('<%#Eval("iEmployeeID") %>','<%# Eval("Request_Type")%>')" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </ContentTemplate>
            </asp:UpdatePanel>

Open in new window



protected void gvSearchResults_RowDataBound(object sender, GridViewRowEventArgs e)
        {
           
            e.Row.Cells[4].Font.Bold = true;
            e.Row.Cells[4].Font.Size = FontUnit.Large;
            if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Request_Type")) == "NEW")
            {
                e.Row.Cells[4].ForeColor = System.Drawing.Color.Green;
                //e.Row.ForeColor = System.Drawing.Color.Red;
            }
            if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Request_Type")) == "EDIT")
            {
                e.Row.Cells[4].ForeColor = System.Drawing.Color.Blue;
                //e.Row.ForeColor = System.Drawing.Color.Red;
            }
            if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Request_Type")) == "TERMINATE")
            {
                e.Row.Cells[4].ForeColor = System.Drawing.Color.Red;
                //e.Row.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                e.Row.ForeColor = System.Drawing.Color.Black;
            }
        }

Open in new window

devnewbeeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
devnewbeeAuthor Commented:
The second link works, but I still lose my header style. :)
0
SAMIR BHOGAYTAFreelancer and IT ConsultantCommented:
<asp:UpdatePanel ID="updpSearch" runat="server">

<Triggers>

<asp:AsyncPostBackTrigger ControlID="btnSearch" />

</Triggers>

<ContentTemplate>

<!-- Panel pSecondStep -->

<asp:Panel ID="pSecondStep" runat="server" Visible="false" Width="100%">

<table cellpadding="2" cellspacing="0" border="2" class="backColor-XLight borderColor-Dark" style="width:100%">

<tr>

<td style="height: 60px">

<asp:Label runat="server" SkinID="SmallTitle" Text="<%$ Resources:Client_Directory, Results %>"> :</asp:Label><br />

<table cellpadding="2" cellspacing="0" border="0" runat="server" id="tSecondStepTables">

<tr>

<td><asp:Literal runat="server" Text="<%$ Resources:Client_Directory, ResultsExpl %>"></asp:Literal></td>

</tr>

<tr>

<td style="width:100%" valign="top">

 

<!-- Panel CssClass="flashThis" -->

<asp:Panel ID="pFlash" runat="server" CssClass="flashThis">

<asp:GridView runat="server" ID="gvCentral" SkinID="mainGrid" AutoGenerateColumns="False" Width="100%" OnRowDataBound="gvCentral_RowDataBound" AllowPaging="True" OnPageIndexChanging="gvCentral_PageIndexChanging" PageSize="15">

<Columns>

<asp:TemplateField HeaderText="&nbsp;">

<ItemTemplate>

<asp:HyperLink ID="HyperLink11" SkinID="MagnifyingGlassLittle" NavigateUrl='<%# String.Format("javascript:windowPop({0});", UrlIdentity(Eval("Id").ToString())) %>' runat="server"></asp:HyperLink>

</ItemTemplate>

</asp:TemplateField>

<asp:BoundField DataField="Title" HeaderText="<%$ Resources:Client_Profile, Title %>" />

<asp:TemplateField HeaderText="&nbsp;<%$ Resources:Client, Lname %>&nbsp;">

<ItemTemplate>

<asp:LinkButton ID="lbFoundMember" runat="server" CommandArgument='<%# Eval("Id").ToString() %>'

OnClick="teamAdd_Click" OnClientClick="return click_subscribe_button(this);"

Text='<%# Eval("LName") %>' ToolTip="<%$ Resources:Client_NewSubscription, addMemberToTeam %>" />

</ItemTemplate>

</asp:TemplateField>

<asp:BoundField HeaderText="<%$ Resources:Client, Fname %>" DataField="FName" />

<asp:BoundField DataField="MLName" HeaderText="<%$ Resources:Client, MLname %>" />

<asp:BoundField DataField="MFName" HeaderText="<%$ Resources:Client, MFname %>" />

<asp:BoundField DataField="Sex" HeaderText="<%$ Resources:Client, Sex %>" />

<asp:TemplateField HeaderText="&nbsp;">

</asp:TemplateField>
</Columns>

<PagerSettings Mode="NumericFirstLast" />

</asp:GridView>

<asp:PlaceHolder ID="phFruitlessSearch" runat="server">

<asp:Literal ID="Literal1" runat="server" Mode="Encode"

Text="<%$ Resources:Client_NewSubscription, noSearchResult %>"></asp:Literal>

</asp:PlaceHolder>

</asp:Panel>

<!-- Panel CssClass="flashThis" END -->

</td>

</tr>

</table>

</td>

</tr>

</table>

</asp:Panel>

<!-- Panel pSecondStep END -->

</ContentTemplate>

</asp:UpdatePanel>

 

====

     protected void loadSearchResult(Control parent)
    {
        MembersSubset s = new MembersSubset(Club.DirectorySubsetId);
        s.EnableSorting = true;
        s.EnableFiltering = true;
        string condition = this.getCondition(parent);
        bool emptySearch = String.IsNullOrEmpty(condition);
        if (emptySearch)
        {
            s.AdditionalFilter = "1 = 2";
        }
        else
        {
            s.AdditionalFilter = condition;
        }
        s.AdditionalPreSorting = "lname, fname, mlname, mfname";
        ArrayList fieldsToHave = new ArrayList(6);

        fieldsToHave.Add("lname");
        fieldsToHave.Add("fname");
        fieldsToHave.Add("mlname");
        fieldsToHave.Add("mfname");
        fieldsToHave.Add("sex");
        fieldsToHave.Add("title");

        // Check if all the fields are present
        if (s.Fields != null) foreach (QueryField qf in s.Fields)
        {
            fieldsToHave.Remove(qf.fieldName.ToLower());
        }

        foreach(string fieldToHave in fieldsToHave)
        {
            QueryField qf = new QueryField(fieldToHave, FieldType.charstring, "members");
            s.AddField(qf);
        }

        s.DataBind();

        GridView gvCentral = (GridView)(parent.FindControl("gvCentral"));
        Panel pSecondStep = (Panel)(parent.FindControl("pSecondStep"));
        PlaceHolder phFruitlessSearch = (PlaceHolder)(parent.FindControl("phFruitlessSearch"));
        gvCentral.DataSource = s.SubsetView;
        gvCentral.DataBind();

        pSecondStep.Visible = this.thisNewSearch;
        phFruitlessSearch.Visible = (gvCentral.Rows.Count == 0);
    }

    protected void gvCentral_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
           
            switch (e.Row.Cells[6].Text.ToLower())
            {
                case "true": e.Row.Cells[6].Text = Resources.Client_Directory.sexMale; break;
                case "false": e.Row.Cells[6].Text = Resources.Client_Directory.sexFemale; break;
            }
            //ScriptManager1.RegisterPostBackControl(e.Row.FindControl("lbFoundMember"));
        }
    }
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

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.