C#에서 보기 처리 ----------RowFilter

2052 단어 filter
    DataView,              .



DataView dv = F.Studio.Trade.BLL.ClassBLL.Query().Tables[0].DefaultView;

dv.RowFilter = "Code='0001'"; //      

dv.RowFilter = "Len(Code)=4";//        

foreach (DataRowView drv in dv)

{

string code = drv["Code"].ToString();

string classname = drv["ClassName"].ToString();

Response.Write(classname + "<br/>");

//         ,  :        dv  

dv.RowFilter="Code Like '" + code +"*' And Len(Code)=" + (code.Length + 4);

foreach (DataRowView drv2 in dv)

{

string code1 = drv2["Code"].ToString();

string classname1 = drv2["ClassName"].ToString();

Response.Write("--" + classname1 + "<br/>");

}

} 

//============           ( foreach  for)

for (int i = 0; i < dv.Count;i++ )

{

string code = dv[i]["Code"].ToString();

string classname = dv[i]["ClassName"].ToString();

Response.Write(classname + "<br/>");

//DataView dv2=new DataView(dv.Table);

//dv2.RowFilter=...

//            ,    dv  dv2         

dv.RowFilter = "Code Like '" + code + "*' And Len(Code)=" + (code.Length + 4);

for (int j = 0; j < dv.Count;j++ )

{

string code1 = dv[j]["Code"].ToString();

string classname1 = dv[j]["ClassName"].ToString();

Response.Write("--" + classname1 + "<br/>");

}

} 

----------------------------

           foreach    IEnumerable   ,DataView       



public IEnumerator GetEnumerator()

        {

        DataRowView[] array = new DataRowView[this.Count];

        this.CopyTo(array, 0);//        

        return array.GetEnumerator();

        }

        

    DataView     RowFilter,            ,   RowFilter   foreach  dataview,             ,    DataView 
RowFilter foreach . DataView tDv=new DataView(DataTable); -- ,
dataView( datatable) foreach , dataview .

 

좋은 웹페이지 즐겨찾기