list<string>绑定到repeater? 如:list<string> list = new List<string>();list.add("aa");list.add("bb");可以直接绑定到repeater吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给出一个很早之前写的代码,请楼主自己观察://实体类和集合,注意该集合类继承的基类using System.Collections.Generic;namespace EBShop.Model{ /// <summary> /// 商品祖类别实体 /// </summary> public class ParentCategoryInfo { #region//私有成员 short parentCategoryID; string parentCategoryName; #endregion #region//公有属性 /// <summary> /// 类别名称 /// </summary> public string ParentCategoryName { get { return parentCategoryName; } } /// <summary> /// 类别编号 /// </summary> public short ParentCategoryID { get { return parentCategoryID; } } #endregion /// <summary> /// 构造函数 /// </summary> /// <param name="pCID">类别编号</param> /// <param name="pCN">类别名称</param> public ParentCategoryInfo(short pCID, string pCN) { this.parentCategoryID = pCID; this.parentCategoryName = pCN; } } /// <summary> /// 祖类别集合 /// </summary> public class ParentCategoryCollection : List<ParentCategoryInfo> { }}//下面是页面中的下拉框(与你的Repeater差不多),注意控件绑定的字段是单体类的属性名称<tr> <td style="width: 100px"> 所属祖类:</td> <td style="width: 100px"> <asp:DropDownList ID="DDL_ParentCategory" runat="server" DataTextField="ParentCategoryName" DataValueField="ParentCategoryID" AutoPostBack="True" OnSelectedIndexChanged="DDL_ParentCategory_SelectedIndexChanged"> </asp:DropDownList></td> <td style="width: 100px"> </td> <td style="width: 100px"> </td> </tr>//然后下面是业务层,就是获取类集合数据,并返回给页面层using System.Collections.Generic;using EBShop.Model;namespace EBShop.BLL{ /// <summary> /// 商品祖类别业务逻辑层 /// </summary> public class ParentCategory { /// <summary> /// 取得祖类别集合 /// </summary> /// <returns>祖类别集合</returns> public ParentCategoryCollection GetParentCategoryList() { ParentCategoryInfo[] arryPCI ={ new ParentCategoryInfo(1,"消费电子"), new ParentCategoryInfo(2,"日用消费品"), new ParentCategoryInfo(3,"其它综合") }; ParentCategoryCollection pCC = new ParentCategoryCollection(); pCC.AddRange(arryPCI); return pCC; } }}//下面是页面.aspx.cs文件中给控件绑定数据源 //祖类别 this.DDL_ParentCategory.DataSource = new ParentCategory().GetParentCategoryList(); this.DDL_ParentCategory.DataBind(); treeview控件里面的事件触发问题,各位大侠帮帮忙啊... 生成静态网页方案,缓存模板,大家探讨一下! 数据库取数据时怎么才能只取前10列的值 一个关于字符串转换的问题 不走寻常路:我发布的网站dll被我删了还能正常访问 这个的报表效果如何实现,柱状图内各项占百分比显示 在ASP.NET里怎样把一个用户POST上来的乱码转换编码 求可同时上载图片 文字的代码! 为什么把cs文件编译为dll文件就找不到定义? 高分之紧急求解:怎样把ASP。NET的程序的数据库转向Access. 主线程等待子线程 asp.net注册与登陆框怎么写 很急!!!
//实体类和集合,注意该集合类继承的基类using System.Collections.Generic;namespace EBShop.Model
{
/// <summary>
/// 商品祖类别实体
/// </summary>
public class ParentCategoryInfo
{
#region//私有成员
short parentCategoryID;
string parentCategoryName;
#endregion
#region//公有属性
/// <summary>
/// 类别名称
/// </summary>
public string ParentCategoryName
{
get { return parentCategoryName; }
}
/// <summary>
/// 类别编号
/// </summary>
public short ParentCategoryID
{
get { return parentCategoryID; }
}
#endregion
/// <summary>
/// 构造函数
/// </summary>
/// <param name="pCID">类别编号</param>
/// <param name="pCN">类别名称</param>
public ParentCategoryInfo(short pCID, string pCN)
{
this.parentCategoryID = pCID;
this.parentCategoryName = pCN;
}
}
/// <summary>
/// 祖类别集合
/// </summary>
public class ParentCategoryCollection : List<ParentCategoryInfo> { }
}
//下面是页面中的下拉框(与你的Repeater差不多),注意控件绑定的字段是单体类的属性名称<tr>
<td style="width: 100px">
所属祖类:</td>
<td style="width: 100px">
<asp:DropDownList ID="DDL_ParentCategory" runat="server" DataTextField="ParentCategoryName" DataValueField="ParentCategoryID" AutoPostBack="True" OnSelectedIndexChanged="DDL_ParentCategory_SelectedIndexChanged">
</asp:DropDownList></td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
//然后下面是业务层,就是获取类集合数据,并返回给页面层
using System.Collections.Generic;using EBShop.Model;namespace EBShop.BLL
{
/// <summary>
/// 商品祖类别业务逻辑层
/// </summary>
public class ParentCategory
{
/// <summary>
/// 取得祖类别集合
/// </summary>
/// <returns>祖类别集合</returns>
public ParentCategoryCollection GetParentCategoryList()
{
ParentCategoryInfo[] arryPCI ={
new ParentCategoryInfo(1,"消费电子"),
new ParentCategoryInfo(2,"日用消费品"),
new ParentCategoryInfo(3,"其它综合")
};
ParentCategoryCollection pCC = new ParentCategoryCollection();
pCC.AddRange(arryPCI);
return pCC;
}
}
}
//下面是页面.aspx.cs文件中给控件绑定数据源
//祖类别
this.DDL_ParentCategory.DataSource = new ParentCategory().GetParentCategoryList();
this.DDL_ParentCategory.DataBind();