Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Asp.Net Programming

Changing data source


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?

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

"Mirnes" <leme@yahoo.com> wrote in message

news:1181121351.548924.85090@h2g2000hsg.googlegroups.com...

Just set myDataSource.SelectCommand = GetDataSource() in the codebehind.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

"Mirnes" <leme@yahoo.com> wrote in message

news:1181121351.548924.85090@h2g2000hsg.googlegroups.com...

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc