|
-
Jul 30th, 2007, 10:11 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Importing Selected rows in a datagrid
Hello everyone,I need help with my program..I just want to know how to link the row i selected to another form? I mean i had already a view on a datagrid coming from my database and i want it to import into another form by just clicking the row i selected. Thanks in advance to those who can help me. Have a nice day!
Last edited by shyguyjeff; Nov 27th, 2007 at 10:14 PM.
-
Jul 30th, 2007, 10:24 PM
#2
Re: Importing Selected rows in a datagrid
You let data-binding take care of most of the work. See this thread for the principles. In .NET 1.x you don't have the BindingSource so you have to get your hands a little bit dirtier. For a start, you'll be binding the Datatable directly to the grid instead of via a BindingSource. That also means that you can't do this:
vb.net Code:
Dim row As DataRow = DirectCast(Me.BindingSource1.Current, DataRowView).Row
In .NET 1.x you have to use the CurrencyManager directly that gets wrapped in the BindingSource in .NET 2.0:
vb.net Code:
Dim row As DataRow = DirectCast(DirectCast(Me.BindingContext(myDataTable), CurrencyManager).Current, DataRowView).Row
I didn't do this sort of thing much before .NET 2.0 so I'm not 100% sure that's correct, but fairly sure.
-
Jul 31st, 2007, 12:38 AM
#3
Thread Starter
Hyperactive Member
Re: Importing Selected rows in a datagrid
i have a few question...What does that myDataTable for?do I need to make a table for that?Since I have already data on a datagrid and i want it to just click the value and automatically it will display on a next form..How can I make a BindingSource?The Code appear a lot of error.
Last edited by shyguyjeff; Jul 31st, 2007 at 12:52 AM.
-
Jul 31st, 2007, 12:50 AM
#4
Re: Importing Selected rows in a datagrid
Where did the data in the DataGrid come from? A DataTable of course.
-
Jul 31st, 2007, 12:56 AM
#5
Thread Starter
Hyperactive Member
Re: Importing Selected rows in a datagrid
what if my data is coming from my database?sorry if i'm so illiterate. The data are coming from my tables of my database. How can I do it?
-
Jul 31st, 2007, 01:06 AM
#6
Re: Importing Selected rows in a datagrid
You retrieve the data from the database into a DataTable and bind that DataTable to the DataGrid. That's how you're displaying the data in the first place. The code above shows you how to get the DataRow from the DataTable that corresponds to the row selected in the grid. The thread I linked to shows you how to pass that DataRow to a dialogue for editing. When you edit that DataRow in the dialogue the DataGrid will update automatically, which is the whole point of data-binding.
-
Jul 31st, 2007, 01:46 AM
#7
Thread Starter
Hyperactive Member
Re: Importing Selected rows in a datagrid
ahhh..i see...so what is the BindingSource stand for?How can I use this code?
-
Jul 31st, 2007, 01:48 AM
#8
Re: Importing Selected rows in a datagrid
As I clearly stated in my first reply, the BindingSource class is not available in .NET 1.x. The second code snippet is the alternative that you need to use instead of the first specifically for that reason. It's all there in the thread already. Please read carefully.
-
Jul 31st, 2007, 02:03 AM
#9
Thread Starter
Hyperactive Member
Re: Importing Selected rows in a datagrid
Okay...Sorry if i keep asking,now i know.Thanks jmcilhinney i will try to follow that steps out there. Have a nice morning. GOd Bless!
-
Jul 31st, 2007, 02:20 AM
#10
Re: Importing Selected rows in a datagrid
There's nothing wrong with asking lots of questions, but it's important to pay attention to the answers when they're provided.
-
Jul 31st, 2007, 03:23 AM
#11
Thread Starter
Hyperactive Member
Re: Importing Selected rows in a datagrid
Okie!Dokie!!!Thanks again jmcilhinney...Have a nice day!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|