Private Void Button#click ( Object Sender, eventargs E)
{
// Using (sqlconnection conn = new sqlconnection (configurationmanager. connectionstrings ["connstr"]. tostring ()))
// {
// Sqldataadapter SDA = new sqldataadapter ("select * From t_class where f_type = 'product' order by f_rootid, f_orders", Conn );
// Dataset DS = new dataset ();
// SDA. Fill (DS, "t_class ");
// // When binding data with dataset, datemember must be specified at the same time.
// // This. Maid = Ds;
// // This. Maid = "t_class ";
// // You can also bind the data sheet directly.
// This. Maid = Ds. Tables ["t_class"];
// }
// Directly bind an array.
Arraylist al = New Arraylist ();
Al. Add ( New Myitem ( " Text1 " , " Value1 " ));
Al. Add ( New Myitem ( " Text2 " , " Value2 " ));
Al. Add ( New Myitem ( " Text3 " , " Value3 " ));
This . Datagridview1.datasource = Al;
}
Class Myitem
{
Private String _ Text;
Private String _ Value;
Public Myitem ( String Text, String Value)
{
This. _ Text=Text;
This. _ Value=Value;
}
Public String Text {
Set {_ Text=Value ;}
Get {Return_ Text ;}
}
Public String Value
{
Set {_ Value=Value ;}
Get {Return_ Value ;}
}
}