473,382 Members | 1,386 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,382 software developers and data experts.

Datagrid / Dataview Help On Select after SORT...

I have a datagrid that I am using a DataView with. All works great for the
sorting of the columns. However, after I sort the column, and then try and
select a data row to edit, the row selected represents the indes of the
actual DataGrid and not the DataView. For example.. Lets say I have 4 rows
of data.. In the 4 rows I have an Appt Num of 1,2,3,4... Each representing
a data row... I sort DESC so the rows display 4,3,2,1... If I select the
2ND row of data, I will see #2 rather Than #3 as I should since the data view
is sorted DESC... PLEASE HELP.. I am sure it is something I am
overlooking... Thanks.. Bruce

Oct 25 '05 #1
4 2408
What you need to do is "locate" the currently selected row in the DataSet
like this:

[VB.NET]

Dim theDataSetRow As DataRow = ds.Tables(0).Select("FieldName ='" &
CType(e.Item.FindControl("controlNameThatWouldHave TheDataInIt"),
controlType).Text & "'")(0)

"Bruce Pullum" <Br*********@discussions.microsoft.com> wrote in message
news:63**********************************@microsof t.com...
I have a datagrid that I am using a DataView with. All works great for the
sorting of the columns. However, after I sort the column, and then try
and
select a data row to edit, the row selected represents the indes of the
actual DataGrid and not the DataView. For example.. Lets say I have 4
rows
of data.. In the 4 rows I have an Appt Num of 1,2,3,4... Each
representing
a data row... I sort DESC so the rows display 4,3,2,1... If I select the
2ND row of data, I will see #2 rather Than #3 as I should since the data
view
is sorted DESC... PLEASE HELP.. I am sure it is something I am
overlooking... Thanks.. Bruce

Oct 25 '05 #2
Bruce,

I assume that you are not using consequently that dataview

Cor

"Bruce Pullum" <Br*********@discussions.microsoft.com> schreef in bericht
news:63**********************************@microsof t.com...
I have a datagrid that I am using a DataView with. All works great for the
sorting of the columns. However, after I sort the column, and then try
and
select a data row to edit, the row selected represents the indes of the
actual DataGrid and not the DataView. For example.. Lets say I have 4
rows
of data.. In the 4 rows I have an Appt Num of 1,2,3,4... Each
representing
a data row... I sort DESC so the rows display 4,3,2,1... If I select the
2ND row of data, I will see #2 rather Than #3 as I should since the data
view
is sorted DESC... PLEASE HELP.. I am sure it is something I am
overlooking... Thanks.. Bruce

Oct 25 '05 #3
Scott, I apologize for my ignorance... However, I am having a hard time with
this code. I have it in the correct place, however, not sure I am using it
correctly..

For the FIELDNAME I have used APPTNO because that is the heading of the
field in the table I would be looking for.. I am not sure what to use for
the e.Item.FindControl("controlNameThatWouldHaveTheDat aInIt"),

Again, I appreciate your help and apologize.... Any additional help will
be appreciated...

Thanks... Bruce

"Scott M." wrote:
What you need to do is "locate" the currently selected row in the DataSet
like this:

[VB.NET]

Dim theDataSetRow As DataRow = ds.Tables(0).Select("FieldName ='" &
CType(e.Item.FindControl("controlNameThatWouldHave TheDataInIt"),
controlType).Text & "'")(0)

"Bruce Pullum" <Br*********@discussions.microsoft.com> wrote in message
news:63**********************************@microsof t.com...
I have a datagrid that I am using a DataView with. All works great for the
sorting of the columns. However, after I sort the column, and then try
and
select a data row to edit, the row selected represents the indes of the
actual DataGrid and not the DataView. For example.. Lets say I have 4
rows
of data.. In the 4 rows I have an Appt Num of 1,2,3,4... Each
representing
a data row... I sort DESC so the rows display 4,3,2,1... If I select the
2ND row of data, I will see #2 rather Than #3 as I should since the data
view
is sorted DESC... PLEASE HELP.. I am sure it is something I am
overlooking... Thanks.. Bruce


Oct 25 '05 #4
e.Item refers to the "row" of the DataGrid that you are working on. Within
that row, you most likely have more than one column, so to be searching the
rows of the grid by a particular field name, you need to find the control in
that row that is supposed to be holding the field data you are looking for
(APPTNO in your case).

When a grid renders its rows, it places its data directly into the cell of
the table (ultimately rendered as a <TD> tag). That makes it difficult to
track down particular cells, so you should manually create columns for your
DataGrid (via the PropertyBuilder dialog of the grid). Start by creating
Bound columns and then click the "Convert to Template column" hyperlink to
make this column a Template column. From there, you can place controls of
your choosing into each column (and most importantly, you can now give that
control an ID of your choosing).

When I say "controlNameThatWouldHaveTheDataInIt", I mean the name of the
control I just mentioned.

I know this sounds confusing and it certainly can be, but to build a good
DataGrid that offers the editing, selecting, sorting, paging capabilities
you seek, it takes a bit of work.

Check out
http://msdn.microsoft.com/library/de...webcontrol.asp
for more details on Template Columns.

-Scott

"Bruce Pullum" <Br*********@discussions.microsoft.com> wrote in message
news:AC**********************************@microsof t.com...
Scott, I apologize for my ignorance... However, I am having a hard time
with
this code. I have it in the correct place, however, not sure I am using
it
correctly..

For the FIELDNAME I have used APPTNO because that is the heading of the
field in the table I would be looking for.. I am not sure what to use for
the e.Item.FindControl("controlNameThatWouldHaveTheDat aInIt"),

Again, I appreciate your help and apologize.... Any additional help will
be appreciated...

Thanks... Bruce

"Scott M." wrote:
What you need to do is "locate" the currently selected row in the DataSet
like this:

[VB.NET]

Dim theDataSetRow As DataRow = ds.Tables(0).Select("FieldName ='" &
CType(e.Item.FindControl("controlNameThatWouldHave TheDataInIt"),
controlType).Text & "'")(0)

"Bruce Pullum" <Br*********@discussions.microsoft.com> wrote in message
news:63**********************************@microsof t.com...
>I have a datagrid that I am using a DataView with. All works great for
>the
> sorting of the columns. However, after I sort the column, and then try
> and
> select a data row to edit, the row selected represents the indes of the
> actual DataGrid and not the DataView. For example.. Lets say I have
> 4
> rows
> of data.. In the 4 rows I have an Appt Num of 1,2,3,4... Each
> representing
> a data row... I sort DESC so the rows display 4,3,2,1... If I select
> the
> 2ND row of data, I will see #2 rather Than #3 as I should since the
> data
> view
> is sorted DESC... PLEASE HELP.. I am sure it is something I am
> overlooking... Thanks.. Bruce
>


Oct 25 '05 #5

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

Similar topics

2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
7
by: DC Gringo | last post by:
I have a datagrid that won't sort. The event handler is firing and return label text, just not the sort. Here's my Sub Page_Load and Sub DataGrid1_SortCommand: -------------------- Private...
2
by: ddaniel | last post by:
I have read many posts and seen many papers on the different techniques for sort and filtering datagrids. Many do re-queries against the dB ala Fritz Onion. I am trying to leverage the Dataview....
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
9
by: John Hernry | last post by:
I have been watching the dotnet newsgroups for a couple of weeks now and scouring the net looking for a solution to my datagrid find functionality. With no luck. I am hoping that you can help me....
4
by: Bruce Pullum | last post by:
I have a datagrid that I am using a DataView with. All works great for the sorting of the columns. However, after I sort the column, and then try and select a data row to edit, the row selected...
0
by: Nathan Franklin | last post by:
Hello Guys, I have been trying to work this our for so long, but I just can't seem to find the answer. I am loading a datatable from a an access database using an oledbdataadapter. I then...
0
by: rn5a | last post by:
A DataGrid control displays records from a SQL Server 2005 DB table. The AllowSorting property of the DataGrid has been set to True & the SortExpressions of the BoundColumns have been set to the...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.