ListBox system.data.datarowview

2 posts, 0 answers
  1. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 14 Oct 2011 Link to this post

    I am sure I am missing something simple here.

    I have created a function to call a storeproc and want to return the results to a listbox:

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        rgd_CurrentGroups.DataSource = GetGroups()
        rgd_CurrentGroups.DataBind()
        RadListBox1.DataSource = GetGroups().DefaultView
        RadListBox1.DataBind()
    End Sub
    Private Function GetGroups() As DataTable
        'Dim UserName As String = Request.QueryString("UserName")
        Dim UserName As String = "fred"
        Dim connectionString As String = DirectCast(ConfigurationManager.ConnectionStrings("IT_CentralConnectionString").ConnectionString, String)
        Dim connection As New SqlConnection(connectionString)
        Dim command As New SqlCommand(connectionString, connection)
        command = New SqlCommand("procGetGroupUsers", connection)
        command.CommandType = CommandType.StoredProcedure
        command.Parameters.Add("@UserName", SqlDbType.VarChar).Value = UserName
        command.Connection.Open()
        Dim myDataAdapter As New SqlDataAdapter(command)
        Dim myDataSet As New DataSet
        Dim dtData As New DataTable
        myDataAdapter.Fill(myDataSet)
        Return myDataSet.Tables(0)
        command.Connection.Close()
    End Function

    If I use a radgrid the grid populates correctly but if I use a listbox the funtion only returns system.data.datarowview.

    Can some one please set me straight.

    Thank you.


  2. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 14 Oct 2011 Link to this post

    Duh...

    Figured it out.

    Just needed to add the field name I am returning from the StoredProc to the DataValueField Setting.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top