Link to home
Start Free TrialLog in
Avatar of tmihalski
tmihalski

asked on

repeater linkbutton to postback to different onItemCommand

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
Avatar of razo
razo

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
Avatar of tmihalski

ASKER

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>
u could pass e from update_pick_list to on_buttonmodelclick. no problem with that
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)
ASKER CERTIFIED SOLUTION
Avatar of razo
razo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial