Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Greetings,

I have created a Dynamic Header in Gridview, in that a link button will be created dynamically in Row_Created Event. On Clicking on this dynamic link button a javascript function is called to raise a ASP button Click event. On Clicking on this Link Button data is saving in database and also populating in DataSet. After gridview DataBind the record count is also showing correctly, but the data is not displaying in Gridview. But after page refresh or clicking on any other button in the page all the records are displaying.

C#
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmOverview.aspx.cs" Inherits="frmOverview"
    Theme="RioTinto" EnableEventValidation="false" EnableViewState="true" %>




Please help me in this.
Please find the below code



C#
public override void VerifyRenderingInServerForm(Control control)
    {

        // Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.
    }
   

protected void gvOverview_RowCreated(object sender, GridViewRowEventArgs e)
    {


 LinkButton lnkSave = new LinkButton();
                lnkSave.Text = "Save";
                lnkSave.ForeColor = System.Drawing.Color.White;
                lnkSave.Font.Underline = true;
                //lnkSave.Click += lnkSave_Click;
                lnkSave.OnClientClick = "ClickEven()";

GridViewRow HeaaderGridRow2 = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);
                HeaaderGridRow2.CssClass = "HeaderFreez";
                HeaaderGridRow2.BackColor = System.Drawing.ColorTranslator.FromHtml("#005b92");

                gvOverview.Controls[0].Controls.AddAt(1, HeaaderGridRow2);
}

in ASPX Page.

C#
<asp:Button ID="btnSave" runat="server" Text="Save&" OnClick="btnSave_Click" Style="display: none;" />


function ClickEven() {
      document.getElementById("btnSave").click();
  }


IT's urgent...
Posted
Updated 10-Aug-14 21:22pm
v4
Comments
pradiprenushe 11-Aug-14 3:24am    
Are you using updtae panel? OR are you calling Gridview databind method at proper place?
Member 10860615 11-Aug-14 3:28am    
Thank u for ur response..
I am not using any Update Panel... After saving the record.. The GridView bind method is calling... in that DataSet the record is visible (Quick Watch). but in Gridview it is not displaying.
pradiprenushe 11-Aug-14 3:33am    
After saving data are you binding gridview again?
Member 10860615 11-Aug-14 4:15am    
Yes.
Member 10860615 11-Aug-14 5:06am    
I could not able to post complete code here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900