Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear
My scenario is when i click on link button in a gridview under row command.First row selected and perform further work.I want to do the same at page load after grid is binded.How could i call row command for the first row at page load using asp.net.

My Code is here
C#
try
       {
           if (e.CommandName == "do")
           {
               GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
               Session["reg_no"] = ((HiddenField)row.FindControl("hidRegNo")).Value;
               string CS_FLAG = ((HiddenField)row.FindControl("hid_Flag")).Value;
               Session["CS_IS_HANDLE"] = ((HiddenField)row.FindControl("hid_IsHandle")).Value;
               if (CS_FLAG == "Y")
               {
                   this.lnk_Enlarge.Visible = false;
                   Panel_Disable();
                   lblStatus.Text = "This Account is locked and has moved to supervisor";
                   ModalPopupExtender.Show();
               }
               else
               {
                   Session["Loan_acct"] = ((HiddenField)row.FindControl("hidLoanNo")).Value;
                   Session["Cycle_cut"] = ((HiddenField)row.FindControl("hidCycleCut")).Value;
                   Session["Bucket_Code"] = ((HiddenField)row.FindControl("hidBucketCode")).Value;
                   Session["Module"] = ((HiddenField)row.FindControl("hid_Mod")).Value;
                   Session["Product"] = ((HiddenField)row.FindControl("hid_Prod")).Value;
                   Session["City"] = ((HiddenField)row.FindControl("hid_City")).Value;
                   Session["Billing_Cycle"] = ((HiddenField)row.FindControl("hid_BillingCycle")).Value;
                   this.Tabs.Visible = true;
                   this.pnl_ActLog.Visible = true;
                   ShowFinancial();
                   ShowSituationSummary();
                   Show_PIL_Overdue();
                   ShowActivity();
                   ShowAppInfo();
                   ShowDelinquencyHistory();
                   ShowSchedule();
                   ShowContacts();
                   Show_Diary();
                   Load_All();
                   Show_Actions();
                   Show_DiaryNote();
                   Reset();
               }
           }
           lbl_Status.Text = "";
       }
       catch (Exception ex)
       {
           throw new Exception("Application Error: " + ex.Message);
       }
Posted
Updated 30-Aug-13 23:13pm
v2

1 solution

If all you are attempting to do is select the first gridview row for editing when the page loads, try setting the EditIndex property of the gridview before you call the grid's DataBind() method. Like so...
C#
GridView1.EditIndex = 0;
 
Share this answer
 
Comments
Joezer BH 1-Sep-13 9:39am    
5ed!
idenizeni 1-Sep-13 19:17pm    
Thanks!
Syed Imran Saeed 2-Sep-13 2:40am    
Dear
I've tried this solution and make this setting with Gridview But no any record is selected by dafault at page load.Kindly,post an another solution.Thanks....
idenizeni 2-Sep-13 19:37pm    
Are you sure you set the EditIndex before you call the DataBind() on the GridView?
Syed Imran Saeed 2-Sep-13 2:40am    
Dear
I've tried this solution and make this setting with Gridview But no any record is selected by dafault at page load.Kindly,post an another solution.Thanks....

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