Solved

repeater linkbutton to postback to different onItemCommand

Posted on 2004-09-14
7
695 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 225 total points
ID: 12082130
if u want to get the commandargumnt of the button
use e.commandargument in ur on_buttonmodelclick
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

705 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