Pass Parameters To Sub

R

rn5a

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top