Pass ASP.Net GridView from one page to another page

前端 未结 6 1584
终归单人心
终归单人心 2021-01-12 13:59

I want to pass all the gridview value into another page I have one gridview in PatientDetails.aspx page and one button as below



        
6条回答
  •  北荒
    北荒 (楼主)
    2021-01-12 14:45

    As i have seen your previous question also, So i can suggest you one thing, rather than keeping your gridview in session(which is expensive) you can use RowCommand event, and after having button here i don't think you need checkbox or chk_CheckedChanged event, you can pass the PatientID to your next page there you can write query to insert selected row data to your new table.

     
           
            
             
           
          
          
        
    
    
    
     protected void gvDoctorList_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                if (e.CommandName == "select")
                {
                    int pID = Convert.ToInt32(e.CommandArgument);
                    // either put ID in session and check 
                    Session["PatientID"] = Convert.ToString(pID);
                    Server.Transfer("Patientstaticformatrix.aspx");
                }
            }
    

    On page_Load Event

     protected void Page_Load(object sender, EventArgs e)
        {
             string pID = Convert.ToString(Session["PatientID"]);
                if(!string.IsNullOrEmpty(pID))
                {
                  int patientID = Convert.ToInt32(pID);
                 //Call Stored procedure which will insert this record with this ID
                 // to another table
                }    
    
        }
    

提交回复
热议问题