By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,758 Members | 1,225 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,758 IT Pros & Developers. It's quick & easy.

Datagrid / Dataview Help On Select after SORT...

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.