Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Dynamic Hyperlink button A to Z 1

Status
Not open for further replies.

Badgers

Programmer
Nov 20, 2001
187
US
Hi,

I have a search page of which a number of link buttons A to Z.

I need to capture the click of each one, and pass to a stored procedure to do filtering.

There must be a more simple way of this with creating the buttons on the fly and using delegates to capture a generic event.

Does anyone have any ideas?

Thanks advance.

 
a repeater and link buttons with the commandarguement set to the letter. then define a handler for the itemcommand event on the repeater. put the logic in this handler.
Code:
<asp:repeater onitemcommand="get_results">
   <itemtemplate>
      <asp:linkbutton commandname="search" commandargument='<%#container.DataItem%>' text='<%#container.DataItem%>' />
   <itemtemplate>
</asp:repeater>

protected override void OnLoad(EventArgs e)
{
   if(IsPostBack) return;
   MyRepeater.DataSource = new string[] {"A", "B", "C", etc. };
   MyRepeater.DataBind();
}

protected void get_results(object sender, ItemCommandEventArgs e)
{
   if(e.CommandName != "search") return;
   AnotherControl.DataSource = GetResultsFor(e.CommandArguement);
   AnotherControl.DataBind();
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Hi

Got a few issues:

<asp:repeater ID="AtoZRepeater" runat="server" onitemcommand="get_results">
<itemtemplate>
<asp:linkbutton ID="AtoZLinkButton" runat="server" commandname="search" commandargument='<%#container.DataItem%>' text='<%#container.DataItem%>' />

</itemtemplate>
</asp:repeater>

I get an error with CS0103: The name 'container' does not exist in the current context.

I populate it with: AtoZRepeater.DataSource = new string[] {"A", "B", "C"};
AtoZRepeater.DataBind();
 
try Container. it's something along those lines.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top