先做一個元件

並在元件裡加一個屬性(封裝欄位)

 

   public IGrouping<object, DataRow> tTable

   {

       set

       {

           this.lblSid.Text = value.FirstOrDefault()["申請人ID"].ToString();

          this.lblName.Text = value.FirstOrDefault()["申請人姓名"].ToString();

           using (DataTable dx = new DataTable())

           {

               this.gvResult.DataSource = value.CopyToDataTable();

               this.gvResult.DataBind();

           }  

       }

   }

 

動態加入元件

 

                              var tList = dt.AsEnumerable().GroupBy(s => s["申請人ID"]);

 

                               foreach (var i in tList)

 

                              {

 

                                   var tt = (UserControl_corlRD0101Table)LoadControl("~/UserControl/corlrd0101table.ascx");                                  

 

                                   tt.tTable = i;

 

                                  this.panTable.Controls.Add(tt);

 

                               }

 

 這樣就可以很快區分不同data的表

, , , , ,

倧齊 發表在 痞客邦 PIXNET 留言(0) 人氣()