473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

lashapositioning in datatables

hi all

i have datatable with columns "id" and "name"

how can i set the position of cursor to the row where "id" equals to, for
example 5?

thanks

Jul 21 '05 #1
8 1195
Hi lasha,

Are you trying to select a row in a datagrid which is bound to a datatable?
Or are you just trying to select a row from a datatable?

Rakesh

"lasha" wrote:
hi all

i have datatable with columns "id" and "name"

how can i set the position of cursor to the row where "id" equals to, for
example 5?

thanks

Jul 21 '05 #2
hi,
i'm trying to select a row from a datatable

"Rakesh Rajan" wrote:
Hi lasha,

Are you trying to select a row in a datagrid which is bound to a datatable?
Or are you just trying to select a row from a datatable?

Rakesh

"lasha" wrote:
hi all

i have datatable with columns "id" and "name"

how can i set the position of cursor to the row where "id" equals to, for
example 5?

thanks

Jul 21 '05 #3
Hi,

You could obtain the DataRow by using the DataTable.Select method, in which
you pass the select expression. In your case, the code might look like this:

DataRow[] myRows = myDataTable.Select("id=5");

HTH,
Rakesh

"lasha" wrote:
hi,
i'm trying to select a row from a datatable

"Rakesh Rajan" wrote:
Hi lasha,

Are you trying to select a row in a datagrid which is bound to a datatable?
Or are you just trying to select a row from a datatable?

Rakesh

"lasha" wrote:
hi all

i have datatable with columns "id" and "name"

how can i set the position of cursor to the row where "id" equals to, for
example 5?

thanks

Jul 21 '05 #4
Hi,

I think this is what you meant - you want only certain rows to be visible in
the datagrid.

For this, you just need to filter the datatable to obtain a dataview, and
bind the datagrid to this dataview (instead of the datatable).

You could create a DataView passing the datatable, filter expressions (eg.
"id=5"), and the rowstate using this constructor
http://msdn.microsoft.com/library/de...ctortopic3.asp

HTH,
Rakesh

"lasha" wrote:
hi

i'm also interestid in moving to the row in datagrid with specified id

thanks

"Rakesh Rajan" wrote:
Hi lasha,

Are you trying to select a row in a datagrid which is bound to a datatable?
Or are you just trying to select a row from a datatable?

Rakesh

"lasha" wrote:
hi all

i have datatable with columns "id" and "name"

how can i set the position of cursor to the row where "id" equals to, for
example 5?

thanks

Jul 21 '05 #5
thank you, for your help,
but i have some different promlem

i want to show all rows in datagrid, but change the current row to the row
with specified id.

thanks again
"Rakesh Rajan" wrote:
Hi,

I think this is what you meant - you want only certain rows to be visible in
the datagrid.

For this, you just need to filter the datatable to obtain a dataview, and
bind the datagrid to this dataview (instead of the datatable).

You could create a DataView passing the datatable, filter expressions (eg.
"id=5"), and the rowstate using this constructor:
http://msdn.microsoft.com/library/de...ctortopic3.asp

HTH,
Rakesh

"lasha" wrote:
hi

i'm also interestid in moving to the row in datagrid with specified id

thanks

"Rakesh Rajan" wrote:
Hi lasha,

Are you trying to select a row in a datagrid which is bound to a datatable?
Or are you just trying to select a row from a datatable?

Rakesh

"lasha" wrote:

> hi all
>
> i have datatable with columns "id" and "name"
>
> how can i set the position of cursor to the row where "id" equals to, for
> example 5?
>
> thanks
>

Jul 21 '05 #6
Hi,

So you basically want to do this:
1. You want to select a row from a datatable which has a specific id value.
2. Once you get the row, you want that row to be the highlighted one in the
datagrid.

Right?

Strangely enough, I had the exact requirement in the opposite way :)

Rakesh

"lasha" wrote:
thank you, for your help,
but i have some different promlem

i want to show all rows in datagrid, but change the current row to the row
with specified id.

thanks again
"Rakesh Rajan" wrote:
Hi,

I think this is what you meant - you want only certain rows to be visible in
the datagrid.

For this, you just need to filter the datatable to obtain a dataview, and
bind the datagrid to this dataview (instead of the datatable).

You could create a DataView passing the datatable, filter expressions (eg.
"id=5"), and the rowstate using this constructor:
http://msdn.microsoft.com/library/de...ctortopic3.asp

HTH,
Rakesh

"lasha" wrote:
hi

i'm also interestid in moving to the row in datagrid with specified id

thanks

"Rakesh Rajan" wrote:

> Hi lasha,
>
> Are you trying to select a row in a datagrid which is bound to a datatable?
> Or are you just trying to select a row from a datatable?
>
> Rakesh
>
> "lasha" wrote:
>
> > hi all
> >
> > i have datatable with columns "id" and "name"
> >
> > how can i set the position of cursor to the row where "id" equals to, for
> > example 5?
> >
> > thanks
> >

Jul 21 '05 #7
hi

i think u r only guy who helps me, :-)

yes u r right, this is what i want to do

so, can u help me

thank again

"Rakesh Rajan" wrote:
Hi,

So you basically want to do this:
1. You want to select a row from a datatable which has a specific id value.
2. Once you get the row, you want that row to be the highlighted one in the
datagrid.

Right?

Strangely enough, I had the exact requirement in the opposite way :)

Rakesh

"lasha" wrote:
thank you, for your help,
but i have some different promlem

i want to show all rows in datagrid, but change the current row to the row
with specified id.

thanks again
"Rakesh Rajan" wrote:
Hi,

I think this is what you meant - you want only certain rows to be visible in
the datagrid.

For this, you just need to filter the datatable to obtain a dataview, and
bind the datagrid to this dataview (instead of the datatable).

You could create a DataView passing the datatable, filter expressions (eg.
"id=5"), and the rowstate using this constructor:
http://msdn.microsoft.com/library/de...ctortopic3.asp

HTH,
Rakesh

"lasha" wrote:

> hi
>
> i'm also interestid in moving to the row in datagrid with specified id
>
> thanks
>
> "Rakesh Rajan" wrote:
>
> > Hi lasha,
> >
> > Are you trying to select a row in a datagrid which is bound to a datatable?
> > Or are you just trying to select a row from a datatable?
> >
> > Rakesh
> >
> > "lasha" wrote:
> >
> > > hi all
> > >
> > > i have datatable with columns "id" and "name"
> > >
> > > how can i set the position of cursor to the row where "id" equals to, for
> > > example 5?
> > >
> > > thanks
> > >

Jul 21 '05 #8
Hi lasha,

Sorry pal - I went to sleep...this time gap thing is one thing that get's
into way every now and then :)...I guess that's why many of the usual ppl
aren't posting....I don't even know whether you will read this post or not :(

AFAIK, there is no 'graceful' strightforward way of doing this...As i said
in my earlier post, the reverse method is quite simple to do. But in this
case, you need a workaround. The reason is that DataGrid.Select accepts only
an integer, and we need to figure out where in the datagrid our selected row
is currently placed. If the user changes the sort, the problem becomes all
the more significant because the position of our row will be different (as
per the sort expression).

In one of my previous projects, we had implemented a lil soluntion which
could be used here as well. The steps are as follows:

1. Programmatically add a new column to your datatable and fill in integers
starting from the first row to the last (1-n). Say, let the column name be
"myID".
2. Select the datarow you need using the select expression (DataTable.Select)
3. Find out the myID value of this row.
4. Use the datagrid.Select method to select that row passing in this integer.
5. Make sure that you handle the datagrid's sort event. When this happens,
you need to reset all the values in the myID column to the way they appear in
the grid. For this, you just access the defaultview of the datatable (which
is the sorted one) and then set the myID values with respect to that. With
this, you will be able to select rows even if the datagrid gets sorted :D

There might be better ways for doing this....I am still searching.

PS: If you want, I could post the code as well.

HTH,
Rakesh

"lasha" wrote:
hi

i think u r only guy who helps me, :-)

yes u r right, this is what i want to do

so, can u help me

thank again

"Rakesh Rajan" wrote:
Hi,

So you basically want to do this:
1. You want to select a row from a datatable which has a specific id value.
2. Once you get the row, you want that row to be the highlighted one in the
datagrid.

Right?

Strangely enough, I had the exact requirement in the opposite way :)

Rakesh

"lasha" wrote:
thank you, for your help,
but i have some different promlem

i want to show all rows in datagrid, but change the current row to the row
with specified id.

thanks again
"Rakesh Rajan" wrote:

> Hi,
>
> I think this is what you meant - you want only certain rows to be visible in
> the datagrid.
>
> For this, you just need to filter the datatable to obtain a dataview, and
> bind the datagrid to this dataview (instead of the datatable).
>
> You could create a DataView passing the datatable, filter expressions (eg.
> "id=5"), and the rowstate using this constructor:
> http://msdn.microsoft.com/library/de...ctortopic3.asp
>
> HTH,
> Rakesh
>
>
>
> "lasha" wrote:
>
> > hi
> >
> > i'm also interestid in moving to the row in datagrid with specified id
> >
> > thanks
> >
> > "Rakesh Rajan" wrote:
> >
> > > Hi lasha,
> > >
> > > Are you trying to select a row in a datagrid which is bound to a datatable?
> > > Or are you just trying to select a row from a datatable?
> > >
> > > Rakesh
> > >
> > > "lasha" wrote:
> > >
> > > > hi all
> > > >
> > > > i have datatable with columns "id" and "name"
> > > >
> > > > how can i set the position of cursor to the row where "id" equals to, for
> > > > example 5?
> > > >
> > > > thanks
> > > >

Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: William Ryan | last post by:
At the risk of sounding like a Big 5 consultant, "It depends". 1) Strongly typed datasets rock, they are faster than untyped, use intellisense... but your reason for wanting to use them is...
2
by: Jade | last post by:
Hi, I just wanted to ask a quick question regarding datasets. I am creating 3 tables using a dataadapter. what i want to know is that is the relationship created between these datatables...
2
by: Z D | last post by:
Hello, I'm currently using Remoting (HTTP/Binary) to remote a simple object. Everything is working fine except for one function that returns an arraylist of datatables. When I call this...
0
by: Gene Ariani | last post by:
I have one dataset that contains two DataTables: DataTable1: Customer_ID 1
4
by: sal | last post by:
Greets, All Converting array formula to work with datatables/dataset tia sal I finally completed a formula I was working on, see working code below. I would like to change this code so it...
5
by: Frank | last post by:
Hello All, I am working on a vb.net app where I need to compare to 2 datatables and determine if a string exists in one or both. The first dt is filled from the db. A form is loaded and the...
3
by: cj | last post by:
I've used datatables and datasets before. Datasets being able to hold more than one table and datatables being only one table. My mind keeps coming up with recordsets. I can't remember how they...
3
by: bbdobuddy | last post by:
Hi, I have two datatables that I want to left outer join and then do some queries on but I having a hard time figuring out how to join the datatables together. One of the datatables comes from...
2
by: riltim | last post by:
Hi, I have a situation where I need to take multiple DataTables and convert them to a single Datatable which would be simple if I didn't need to convert them into a matrix where like items will...
0
by: StefanPienaar | last post by:
Hi Guys Is there any way in c# (or vb.net) to extract a datatable of data from a dataset with multiple datatables which has relationships set up (containing combined data from the datatables)? ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.