Changing data source

M

Mirnes

I'm trying to change my datasource of datalist depending of listbox
value:

Listbox:

<asp:DropDownList ID="ListCriteria" runat="server"
AutoPostBack="True">
<asp:ListItem Selected="True"
Value="1">Positive</asp:ListItem>
<asp:ListItem Value="2">Negative</
asp:ListItem>
<asp:ListItem Value="3">All</asp:ListItem>
</asp:DropDownList><br />


Function:
Function GetDataSource()

Dim VarDataSource As String
If Me.ListCriteria.SelectedValue = 1 Then
VarDataSource = "SELECT * FROM [CustomerList] WHERE
Amount>0"

ElseIf Me.ListCriteria.SelectedValue = 2 Then
VarDataSource = "SELECT * FROM [CustomerList] WHERE
Amount<0"

Else
VarDataSource = "SELECT * FROM [CustomerList]"

End If

Return VarDataSource
End Function

SelectCommand:

SelectCommand="<%#GetDataSource().ToString()%>"


I don't get any records back. Off course, when I try to do this
manually with criteria from ListBox it works fine.


Any suggestions?
 
V

verci

Hi Mirnes,

Your function is not defined correctly, it should be:

Function GetDataSource(ByVal X as Integer) as String
some code
return
End Function


Hope this helps,
Verci
 

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

Top