?
Solved

repeater linkbutton to postback to different onItemCommand

Posted on 2004-09-14
7
Medium Priority
?
698 Views
Last Modified: 2008-02-01
hello.

Inside of an asp:repeater, is it possible to postback to a different postback function on mouseClick?  For instance, instead of the following being posted back to "Update_Pick_List", the user could post back to "On_ButtonModelClick" as if the OnItemCommand was listed that way in the asp:repeater tag.
===== code behind=====
Sub On_ButtonModelClick( s As Object, e As RepeaterCommandEventArgs )
...
End Sub

Sub Update_Pick_List( s As Object, e As RepeaterCommandEventArgs )
...
End Sub
=====HTML=====
<asp:Repeater id="rptPickList" Runat="Server" OnItemCommand="Update_Pick_List">
    <ItemTemplate>
        <asp:LinkButton id="update" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "PartNo") %>' CommandName='<%# DataBinder.Eval(Container.DataItem, "PartQuantity") %>' Text='update' runat="server" />
        <%-- Is it possible to post back this link to "On_ButtonModelClick"??? --%>
          |  <asp:LinkButton id="update" CommandArgument='<%# Container.DataItem( "modelid" ) %>' CommandName='<%# Container.DataItem( "modelno" ) %> Text='viewModel' runat="server" />
    </ItemTemplate>
</asp:Repeater>

thanks in advance,
~T
0
Comment
Question by:tmihalski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 8

Expert Comment

by:razo
ID: 12062320
well u can only have one function that handles the onitemcommand event
inside this function u can check the id of the button that caused the event and call the function u need
but u need to have different ids for the different linkbuttons
use e.commandname to determine the button clicked
0
 

Author Comment

by:tmihalski
ID: 12064497
right (changed ids below).  This is something like what I'm doing now (detecting linkbutton ids).

On this note, is it possible to "simulate" the passing of RepeaterCommandEventArgs from one sub to another?  For instance (using the below function names), Once inside "Update_Pick_List", detect the linkbutton id, then redirect to On_ButtonModelClick.  I could pass vars to On_ButtonModelClick, but it wouldn't be a RepeaterCommandEventArg.  How would I simulate this?

===== code behind=====
Sub On_ButtonModelClick( s As Object, e As RepeaterCommandEventArgs )
...
End Sub

Sub Update_Pick_List( s As Object, e As RepeaterCommandEventArgs )
...
End Sub
=====HTML=====
<asp:Repeater id="rptPickList" Runat="Server" OnItemCommand="Update_Pick_List">
    <ItemTemplate>
        <asp:LinkButton id="update" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "PartNo") %>' CommandName='<%# DataBinder.Eval(Container.DataItem, "PartQuantity") %>' Text='update' runat="server" />
        <%-- Is it possible to post back this link to "On_ButtonModelClick"??? --%>
          |  <asp:LinkButton id="modeldisplay" CommandArgument='<%# Container.DataItem( "modelid" ) %>' CommandName='<%# Container.DataItem( "modelno" ) %> Text='viewModel' runat="server" />
    </ItemTemplate>
</asp:Repeater>
0
 
LVL 8

Expert Comment

by:razo
ID: 12072299
u could pass e from update_pick_list to on_buttonmodelclick. no problem with that
0
 

Author Comment

by:tmihalski
ID: 12075768
ok, that's great.  I do not get an error when I use the following:

On_ButtonModelClick(Me, e)

However, how do I get the values into e when I call the function?  That is my real question.  I am trying things like the following, but I am unsuccessful:

Dim args2 As New CommandEventArgs(myModelNo, myModelId)
CommandEventArgs e = New CommandEventArgs(nothing, args2)
Raise On_ButtonModelClick(Me, e)
0
 
LVL 8

Accepted Solution

by:
razo earned 900 total points
ID: 12082130
if u want to get the commandargumnt of the button
use e.commandargument in ur on_buttonmodelclick
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question