Repeate binding the third small bench

Source: Internet
Author: User

DESIGN: There are two items: "title" and "content". The first entry does not display "content ". Click "title" to expand and contract "content ".
First:

. Aspx File
<ItemTemplate>
<Span class = "date">
<Asp: Button ID = "BtnContent" Font-Bold = '<% # GetBoldFlag (DataBinder. eval (RepeaterItem) Container ). dataItem, "ID "). toString () %> 'runat = "server" Height = 16 BackColor = LightCyan CssClass = "HomeEntryTitle" Text = '<% # DataBinder. eval (RepeaterItem) Container ). dataItem, "Title") %> 'borderstyle = none CommandArgument = '<% # DataBinder. eval (RepeaterItem) Container ). dataItem, "EntryName "). toString () %> '>
</Asp: Button>
</Span>
<Asp: Literal runat = "server" Visible = '<% # isVial (DataBinder. eval (RepeaterItem) Container ). dataItem, "EntryName "). toString () %> 'text = '<% # DataBinder. eval (RepeaterItem) Container ). dataItem, "Description "). toString () %> 'id = 'scrilit'>
</Asp: Literal>
</ItemTemplate>
</Asp: repeater>

. Cs has two functions:
Private void RecentPosts_ItemCommand (object source, System. Web. UI. WebControls. RepeaterCommandEventArgs e)
{
EntryName = e. CommandArgument. ToString (). Trim ();
String A_entryName = ViewState ["entryName"] as string;

If (A_entryName = null | A_entryName! = EntryName)
{
ViewState ["entryName"] = entryName;
// You can only bind the Helper function to one place. Please note that you can pull it!
}
Else
{
ViewState ["entryName"] = "ToClose ";
}

BindContextPost ();
}

Protected bool isVial (string Arg)
{
If (ViewState ["entryName"]! = Null)
{
EntryName = ViewState ["entryName"]. ToString ();
If (Arg. Trim () = entryName)
{
Return true;
}

}
Return false;
}

Second:
. Aspx File
<Asp: Literal runat = "server" Visible = false Text = '<% # DataBinder. eval (RepeaterItem) Container ). dataItem, "Description "). toString () %> 'id = 'scrilit'>


. Cs has a function:
Private void RecentPosts_ItemCommand (object source, System. Web. UI. WebControls. RepeaterCommandEventArgs e)
{
Bool open = (ViewState ["IsOpen"] = null )? False: (bool) ViewState ["IsOpen"];

E. Item. Controls [6]. Visible = open;
ViewState ["IsOpen"] =! Open;
}

Third:
. Aspx File
<Asp: Literal runat = "server" Visible = false Text = '<% # DataBinder. eval (RepeaterItem) Container ). dataItem, "Description "). toString () %> 'id = 'scrilit'>


. Cs has a function:
Private void RecentPosts_ItemCommand (object source, System. Web. UI. WebControls. RepeaterCommandEventArgs e)
{
E. Item. Controls [7]. Visible =! E. Item. Controls [7]. Visible;
}

Look, the expansion of Hehe and repeated can be so simple!

However, I have encountered a problem. After the repeated is expanded, it cannot be automatically located at the expansion location. This is also an old problem for server refreshing. But I thought of several ways, it doesn't feel good to use an anchor or websevice. Ask experienced users how to do this.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.