web:
if (!IsPostBack)
this.GridView1.Sort("ID", SortDirection.Ascending);
BLL
DAL
<add name="WS2ConnString" connectionString="Data Source=./SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Warehouse2.mdf" providerName="System.Data.SqlClient"/>
<asp:GridView ID="gvTraderFavourable" runat="server" AutoGenerateColumns="False"
DataKeyNames="TraderFavourableInfoID" AllowSorting="true" OnRowCommand="gvTraderFavourable_RowCommand"
OnSorting="gvTraderFavourable_Sorting">
<asp:HiddenField ID="HidSortDirection" Value="DESC" runat="server" />
<asp:HiddenField ID="HidSortExpression" Value="TraderFavourableInfoID" runat="server" />
Repeater 内嵌Repeater/datalist
int cityID = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "CityID").ToString());
protected void rptHotel_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
HiddenField hidHotelID = e.Item.FindControl("hidHotelID") as HiddenField;
Repeater rptGuestRoom = e.Item.FindControl("rptGuestRoom") as Repeater;//找到里层的repeater对象
rptGuestRoom.DataSource = ds;
rptGuestRoom.DataBind();
}
}
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
Repeater rep=(Repeater)e.Item.FindControl("Repeater_VODMovies");
int cid=int.Parse((Datalist_VODCategory.DataKeys[e.Item.ItemIndex]).ToString());
DataView view=table;
view.RowFilter="SubCategoryID='"+cid+"'";
rep.DataSource=view;
rep.DataBind();
}
Repeater
foreach (Control c in this.rptEstablishment.Controls)
{
CheckBox chkEstablishmentAll = c.FindControl("chkEstablishmentAll") as CheckBox;
if (chkEstablishmentAll != null)
{
if (chkEstablishmentAll.Checked)//不限不选中时
{
hotelEstablishment = "";
break;
}
}
}
HOW TO:使用嵌套 Repeater 控件和 Visual C# .Net 显示分层数据
http://support.microsoft.com/kb/306154/zh-cn?spid=1108&sid=global
子Repeater 取夫Repeater 的值