?
Solved

Displaying data in a DataRepeater Control in VB.net

Posted on 2009-02-13
4
Medium Priority
?
1,718 Views
Last Modified: 2013-11-26
Hi

I'm trying to display some data from a MySQL database on a form using a DataRepeater control. I have had a looked at a few articles on this and they suggest that I need to create a datasource and bind it to the datarepeater control. This link explains how to do this.
http://social.msdn.microsoft.com/Forums/en-US/vbpowerpacks/thread/1cb3f796-29f4-4556-84b3-d4de0ebef8c7/

However, I would like to bind the DataRepeater and its contents manually in vb code rather than using the wizard.  The link above gives some ideas of how to do this in code (near the bottom) but it does not explain how to bind controls within the the DataRepeater to the data and display the results.

I have attached a code snippet of the code behind the form as it stands. Basically when the form load, it will query a database and then print the data in the console window. This part is working fine. What I would like to do now, is to add a DataRepeater control to the form and display the results in the DataRepeater rather than the console window but I would like to do this using vb code rather than using drag and drop.

Could some please give me some sample code on how this can be achived (baring in mind that I am a beginner in vb.net)?

Many thanks for your help.

Rob

'Test Form
Public Class frmMovieList
 
    Private Sub frmMovieList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        If frmMain.titleSearch = True Then
'strTitle is a string variable
            Dim queryString As String = "SELECT * FROM movies where title like '%" & frmMain.strTitle & "%' OR title like '" & frmMain.strTitle & "%'"
 
            Dim myCommand As New MySqlCommand(queryString, frmMain.myConnection)
            Dim myDataReader As MySqlDataReader
            frmMain.myConnection.Open()
            myDataReader = myCommand.ExecuteReader()
 
            While myDataReader.Read
                Console.WriteLine(myDataReader("Title"))
            End While
 
            myDataReader.Close()
            frmMain.myConnection.Close()
 
        Else
            MsgBox("nothing to do")
        End If
 
    End Sub
 
End Class

Open in new window

0
Comment
Question by:shorak
  • 2
  • 2
4 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 23633519
0
 
LVL 11

Author Comment

by:shorak
ID: 23660230
Hi.. thanks for the link.. I followed it through and got my datarepeater working. I have added two textboxes to my datarepeater and have formatted them so that they are read only and dont have any borders. In the datarepeater display, I am getting a black line in between each row as well as a 'record select?' type button to the left. I have managed to remove the button from the display but am having trouble removing the line between each row.. do you know if it can be done?

Thanks again for your help.

Rob
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 23660442
I really don't think it can be done. See this question that has been asked to the team responsible for this component: http://social.msdn.microsoft.com/Forums/en-US/vbpowerpacks/thread/7931394f-e13a-436a-8192-41e28f4c84fa/
0
 
LVL 11

Author Closing Comment

by:shorak
ID: 31546578
Thanks for your help.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question