Link to home
Start Free TrialLog in
Avatar of shorak
shorakFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Passing values from a DataRepeater control in VB.net

Hello everyone.

I have a dataRepeater on a form that displays some data from an underlying DataTable 'dsMovies'. The data repeater contains a textbox that is bound to a field in the data table  (see code below)

        tbMovieNames.DataBindings.Add(New Binding("Text", dsMovies, "title"))

        DataRepeater1.DataSource = dsMovies
        DataRepeater1.AllowUserToAddItems = False
        DataRepeater1.AllowUserToDeleteItems = False

The dataRepeater displays the data (which is a list of movies) as intended. What I want to do now, is to collect some values from a row when the user clicks on the textbox in the datarepeater. E.g. If a user clicks on a textbox (that displays the movie title), I want to save the movieID of that selected title in a global variable and then open another form that will display more information about the selected movie.

I dont have any problems opening a new form when the textbox is clicked on but I dont know how to save the movieid of the selected record. The underlying data table retrieves movieid, title and year from the database.

Could someone give me a step by step guide on how to do this?

Many thanks

Rob
Avatar of daveamour
daveamour
Flag of United Kingdom of Great Britain and Northern Ireland image

Is this a Repeater or a Gridview?
This is a Winforms app right?
Avatar of shorak

ASKER

Its a dataRepeater control (part of Vb Powerpack 3) and yes.. it is a winforms app. I am guessing that it behaves similarly to a datagridview control but allows you to create a custom layout of the fields as well as adding controls to each row.

Rob
Ok well certainly in a GridView you can have an event handler for code such as CellClick eg:
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
    MessageBox.Show(e.RowIndex.ToString());
}
Are there not simillar events in the Repeater Control?
Avatar of shorak

ASKER

I'm quite new to vb.net so I'm not sure if if a datarepeater control has an even handler. I have found this link that might help but I think the code is in C# and not vb.net.
http://www.vbforums.com/showthread.php?t=557147

any ideas?

Rob
SOLUTION
Avatar of daveamour
daveamour
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial