Home > Net >  How to obtain a value in a DataTable line number
How to obtain a value in a DataTable line number

Time:05-15

 public DataTable Newds (DataSet dsSource) 
{
The DataTable dn=dsSource. Tables [0];
The DataTable da=GetYiZhuFeiYong (DangAnId). Tables [0].
The DataTable dtNewHuiZong=dn. Copy ();
for (int i=0; I & lt; Dn. Rows. Count; I++)
{
Int index=0;
For (int j=0; J & lt; Da. Rows. Count; J++)
{
DataRow dnNew=dtNewHuiZong. NewRow ();
If (dn) Rows [I] [r]. "yizhuid" ToString ()==da. The Rows [j] [r]. "yizhuid" ToString ())
{
If (index==0)
{
//dtNewHuiZong PrimaryKey=new System. The Data. The DataColumn [] {dtNewHuiZong. Columns [" yizhuid "]}.
System. Data. DataRow row=dtNewHuiZong. Rows. The Find (dn) Rows [I] [r]. "yizhuid" ToString ());
DtNewHuiZong. Rows. Remove (row);
}
DnNew [" XiangMuMingCheng "]=da. Rows [j] [r]. "mingcheng" ToString ();
DnNew [" GuiGe "]="& amp; Have spent ";
DnNew [" JiLiang "]="& amp; Have spent ";
DnNew [" YongFa "]="& amp; Have spent ";
DnNew [" DCRenYuan "]="& amp; Have spent ";
"ColSpan" dnNew []=dn. Rows [I] [r]. "ColSpan" ToString ();
DnNew [" PinCi "]="& lt; Span style="color: red '& gt;" + da. Rows [j] [r]. "shuliang" ToString () + "& lt;/span> ";
DnNew [" JinE "]="& amp; Have spent ";
DnNew (" Display ")="Display: none;";
DnNew [" DisplayChangQi "]="display: none;";
DnNew [" XiaDaNianYueRi "]=dn. Rows [I] [r]. "XiaDaNianYueRi" ToString ();
DnNew [" XiaDaYueRi "]=dn. Rows [I] [r]. "XiaDaYueRi" ToString ();
DnNew [" XiaDaShi "]=dn. Rows [I] [r]. "XiaDaShi" ToString ();
DnNew [" ZhiXingYueRi "]=dn. Rows [I] [r]. "ZhiXingYueRi" ToString ();
DnNew [" XiaDaYiSheng "]=dn. Rows [I] [r]. "XiaDaYiSheng" ToString ();
DnNew [" ZhiXingShi "]=dn. Rows [I] [r]. "ZhiXingShi" ToString ();
DnNew [" ZhiXingHuShi "]=dn. Rows [I] [r]. "ZhiXingHuShi" ToString ();
DnNew [" TingZhiYueRi "]=dn. Rows [I] [r]. "TingZhiYueRi" ToString ();
DnNew [" TingZhiShi "]=dn. Rows [I] [r]. "TingZhiShi" ToString ();
DnNew [" TingZhiYiSheng "]=dn. Rows [I] [r]. "TingZhiYiSheng" ToString ();
DnNew [" TingZhiHuShi "]=dn. Rows [I] [r]. "TingZhiHuShi" ToString ();
//dnNew [" yizhuid "]=da. Rows [j] [r]. "yizhuid" ToString ();
DtNewHuiZong. Rows. InsertAt (dnNew, 1);
Index++;
continue;
}

}
}
//for (int I=dtNewHuiZong. Rows. The Count - 2; I & gt; 0; I -)
//{
//DataRow [] rows=dtNewHuiZong. Select (the string. Format (" {0}='{1} ", "yizhuid", dtNewHuiZong. Rows [I] [r]. "yizhuid" ToString ()));
//if (rows. Length & gt; 1)
//{
//dtNewHuiZong. Rows. RemoveAt (I);
//}
//}
DataView dw=dtNewHuiZong. DefaultView;
Dw. Sort="XiaDaNianYueRi desc, XiaDaShi desc";
DtNewHuiZong=dw. ToTable ();
Return dtNewHuiZong;
}

Attached code, said the logic, it is now according to the first datatable circulation of a list of values to add a new datatable, but for now to put the new datatable only shows that the new value, the value of the first data table to delete, you great god can provide the way of thinking, suggestion, or PS: now spelled wrong

CodePudding user response:

This is... Code that... Describe why the language can not convey the information?
  •  Tags:  
  • C#
  • Related