public struct arrWare{
public int id;
public string name;
public string desc;
}
public IList <arrWare> GetWares()
{
IList <arrWare> wares = new List <arrWare> ();
//IList <CustomersM> customer = new List <CustomersM> ();
strSql = "select top 10 infoName,infos,infoId from WareInfo ";
//SqlParameter parms = new SqlParameter( "@id ", SqlDbType.Int);
//parms.Value = id;
using (SqlDataReader rdr = SqlHelper.ExecuteReader(CommandType.Text, strSql, null))
{
arrWare ar = new arrWare();
while (rdr.Read())
{
ar.name = rdr.GetString(0);
ar.desc = rdr.GetString(1);
ar.id = rdr.GetInt32(2);
wares.Add(ar);
}
return wares;
}
}
这获得的数据咱个使用呢?如有一个label控件,怎么才能把它的Text属性设为我这获得的ar.name
------解决方案--------------------------------------------------------
<asp:GridView ID= "GridView1 " runat= "server " DataSourceID= "SqlDataSource1 "> </asp:GridView> <asp:SqlDataSource ID= "SqlDataSource1 " runat= "server " ConnectionString= "Data Source=.;Initial Catalog=Test;User ID=sa;pwd=sa " ProviderName= "System.Data.SqlClient " SelectCommand= "SELECT * FROM [表] where Name like '% '+@Name+ '% ' "> <SelectParameters> <asp:ControlParameter ControlID= "DropDownList1 " Name= "Name " Type= "String " /> </SelectParameters> </asp:SqlDataSource>