Avatar of benchmark_consulting
benchmark_consulting
Flag for United States of America

asked on 

ASP.NET C# LinkButton onClick executes code on page_load

Help!

I have code that I would like to work the following way:

DataGrid has a linkbutton :  GetDetail
When clicked it should execute function GetLoanDetail("LOAN_NUMBER")

the function sets a session var and then rebinds a formview control

what happens is on page_load, asp.net when creating the linkbuttons in the datagrid executes the rebind code and the page is not right.  below is the code that does this:



Function: GetLoanDetail

public static string GetLoanDetail(String LoanID)
    {
       
        string result = string.Empty;
        HttpContext.Current.Session["currentLoanNumber"] = LoanID.ToString();
       
        //formViewLoanDetail.DataSource(dsAccountDetailQY);
        FormView formViewLoanDetail = new FormView();


        formViewLoanDetail.DataBind();

        return result;

    }



Link Button Line:

<asp:LinkButton ID="lnkButtonGetLoanDetail" runat="server" Text="Get Loan Detail" OnClick='<%# GetLoanDetail(Eval("LOAN_NUMBER").ToString()) %>'></asp:LinkButton>            

This is very important and i have assigned 500 points. Thanks in advance!!!
.NET ProgrammingC#

Avatar of undefined
Last Comment
benchmark_consulting

8/22/2022 - Mon