namespace Yin
{
public class wares{
public struct arrWare{
public int id;
public string name;
public string desc;
}
#region Get product information
public IList
{
IList
//IList
strSql = “select top 10 infoName,infos,infoId from WareInfo”;
//IList
strSql = “select top 10 infoName,infos,infoId from WareInfo”;
@id”, SqlDbType.Int);
//parms.Value = id;
using (SqlDataReader rdr = SqlHelper.ExecuteReader(CommandType.Text, strSql, null))
arrWare ar = new wares.arrWare();
While (rdr.Read())
{
Getar( rd. Getc rd) String
Getc
String
1);
ar.id = rdr.GetInt32(2);
Wares.add (ar);
}
Return Wares;
}
}
#ENDREGION
} p>
reference method:
WareInfo Wareinfo = new WareInfo();
IList
Write foreach (wares.arrWare a in ars)
{m br> node textWriter.WriteStartElement(“item”);
TextWriter(Writer Stringa);
Stringbr> WriteEndElement();
Write EndElement();
// Write to node link
textWriter.WriteStartElement(“link”, “”);
http://www.wordware.com/, 888View 2 id=”+a.id);
textWriter.WriteEndElement();
// write node description
textWriter.Writer.Star tElement(“description”, “”);
Write to ElementD textWriter.Writer.WriteString(a.desc);
Write to “TextWriter.WriteEndElement();
“TextWriter” Pub. , “”);
Write to Element textWriter.WriteString(DateTime.Now.ToString());
Write Element(Start); Author textWriter.WriteEndElement();
Author textWriter.WriteEndElement();
Author “”);
Element textWriter.WriteString(“何永”);
TextWriter.WriteEndElement();
End of write element
End of writing element
}
1.
Since what is obtained is a collection, it should be displayed with a list control, such as GridView
GridView1.DataSource = new arrWare().GetWares();
GridView1.DataBind();
2.
Get a single record
arrWare aw = new arrWare().GetWares()[0];
MyLabel.Text = aw.name;
3.
Actually, here you The arrWare should be defined as class, not struct
4.
In addition, for the method GetWares(), it is more appropriate to define static.
System.Collections.Generic.List
“; }