Load GridView data within Panel which is displayed by ModalPopupExtender

I have a modal pop up extender that is used to dispaly a panel which has a grid view.
Currently the panel has a grid view which is bound to a sql data source.
Also there is an OnLoad method that is invoked to get the data on Page Load.

I do not want to have an OnLoad method bt default, I only want to get the data if the user has clicked the link button, how can I achieve this
Below is the code with the OnLoad feature
<ajaxToolkit:ModalPopupExtender ID="mpSelect" runat="server"
                   TargetControlID="lnkSelect" 
                   PopupControlID="pnlSelect"
                   DropShadow="True" 
                   CancelControlID="btnCancel" 
                    OnCancelScript="CloseModal('client');"
                   OnLoad="LoadSelect"
                   BackgroundCssClass="BackgroundStyle"
                    BehaviorID="pnlSelect"
               />
			   
			    <asp:LinkButton ID="lnkSelect" runat="server" OnClientClick="OpenModal('client')" ></asp:LinkButton>

Open in new window

LVL 1
countrymeisterAsked:
Who is Participating?
 
SAMIR BHOGAYTAFreelancer and IT ConsultantCommented:
Hi, use this example, in this example we are using web service.

private void FillGridViewWithCustomerInfo()
{
    string sql = "Select * from customers";
    SqlDataAdapter da = new SqlDataAdapter(sql, “Your connection string”);
      DataTable dt = new DataTable();
      da.Fill(dt);
    GridView1.DataSource = dt;
    GridView1.DataBind();
}

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        HyperLink HyperLink1 = (HyperLink)e.Row.FindControl("HyperLink1");
        HyperLink1.Attributes.Add("onclick", "ShowMyModalPopup('" + GridView1.DataKeys[e.Row.RowIndex].Value + "')");
    }
}

more on this link
http://www.aspdotnetcodes.com/Ajax_ModalPopup_PostBack_GridView.aspx
0
 
CodeCruiserCommented:
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.