Solved

repeater linkbutton to postback to different onItemCommand

Posted on 2004-09-14
7
688 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
  • 3
  • 2
7 Comments
 
LVL 8

Expert Comment

by:razo
Comment Utility
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
Comment Utility
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
Comment Utility
u could pass e from update_pick_list to on_buttonmodelclick. no problem with that
0
 

Author Comment

by:tmihalski
Comment Utility
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
Comment Utility
if u want to get the commandargumnt of the button
use e.commandargument in ur on_buttonmodelclick
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now