Datatable dt = new datatable ();
Datacolumn Dc = new datacolumn ();
DC. columnname = "ID ";
DC. datatype = type. GetType ("system. int32 ");
Datacolumn DC2 = new datacolumn ();
Dc2.columnname = "name ";
Dc2.datatype = type. GetType ("system. String ");
DT. Columns. Add (DC );
DT. Columns. Add (DC2 );
Datarow DR = DT. newrow ();
Dr [0] = 1;
Dr [1] = "mj ";
Datarow DR2 = DT. newrow ();
DR2 [0] = 2;
DR2 ["name"] = "ly ";
DT. Rows. Add (DR );
DT. Rows. Add (DR2 );
Gridview1.datasource = DT;
Gridview1.databind ();
Datarow [] dr3 = DT. Select ("name = 'mj '");
Datatable dt2 = DT. Clone ();
/* Datacolumn DC3 = new datacolumn ();
Dc3.columnname = "ID ";
Dc3.datatype = type. GetType ("system. int32 ");
Datacolumn dc4 = new datacolumn ();
Dc4.columnname = "name ";
Dc4.datatype = type. GetType ("system. String ");
Dt2.columns. Add (DC3 );
Dt2.columns. Add (dc4 );*/
For (INT I = 0; I <dr3.length; I ++)
{
Dt2.importrow (dr3 [I]);
}
If (dt2.rows. Count> 0)
{
Foreach (datarow DR5 in dt2.rows)
{
Response. Write (DR5 [0]. tostring ());
}
}
Gridview2.datasource = dt2;
Gridview2.databind ();
Response. Write (dr3 [0] ["ID"]. tostring ());