Pass Parameters To Sub

Discussion in 'ASP .Net' started by rn5a@rediffmail.com, Nov 7, 2006.

  1. Guest

    An ASP.NET app retrieves 3 columns named Product, Category & Price from
    a SQL Server 2005 DB table & displays them in a DataList. The headers
    of these 3 columns in the DataList are Product, Category & Price
    respectively.

    I want to give users the option to sort the items in the DataList. All
    the 3 columns can be sorted by clicking the headers which are
    LinkButtons. To do this, I want to invoke a sub-routine named
    SortDataList which expects a parameter (which is the column header) but
    when I try to pass the parameter in this way

    <script runat="server">
    Sub SortDataList(ColumnName As String)
    ..........
    ..........
    End Sub
    </script>
    <form runat="server">
    <asp:DataList ID="dList1" runat="server">
    <HeaderTemplate>
    <table border=2>
    <tr>
    <th><asp:LinkButton ID="lnkProduct" OnClick="SortDataList('Product')"
    Text="PRODUCT" runat="server"/></th>
    <th><asp:LinkButton ID="lnkCategory" OnClick="SortDataList('Category')"
    Text="CATEGORY" runat="server"/></th>
    <th><asp:LinkButton ID="lnkPrice" OnClick="SortDataList('Price')"
    Text="PRICE" runat="server"/></th>
    </tr>
    </HeaderTemplate>
    ...........
    ...........
    </asp:DataList>
    </form>

    ASP.NET generates the

    Expression expected.

    error pointing to the first LinkButton code line. I tried other
    combinations & permutations of single quotes & double quotes but
    ASP.NET either generates the above error or the

    Identifier expected.

    error. Can't a sub-routine be invoked by passing a parameter in the way
    I have shown above?
    , Nov 7, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. THY
    Replies:
    1
    Views:
    383
    Steve C. Orr, MCSD
    Aug 19, 2003
  2. Kathy Burke
    Replies:
    3
    Views:
    381
    Kathy Burke
    Nov 24, 2003
  3. Tee
    Replies:
    2
    Views:
    787
  4. Ben
    Replies:
    2
    Views:
    853
  5. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    1,934
    Lawrence D'Oliveiro
    May 20, 2011
Loading...

Share This Page