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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

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

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
CodeCruiserCommented:
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
AJAX

From novice to tech pro — start learning today.