DataViewManager

G

Guest

Hello,
i have 2 Questions about DataViewManager

Q1. I have a dataviewmanager on which I perform some sorts.After sorting,I
need to loop through all the sorted rows to add new column serial Number. If
I loop in regular way,it gives me all the rows in the table and not the
sorted ones.

Q2.I have dataviewmanager with 2 relations.Both the tables are in the same
dataset.I bind the tables to 2 different datagrids.But if I perform a sort or
filter in parent table,it does not update the second grid.It just updates the
first grid.I would like to know,how can I update the second grid,if I perform
a sort on first grid.

Thanks,
Vishal
 
J

Jeff B.

Q1. I have a dataviewmanager on which I perform some sorts.After sorting,I
need to loop through all the sorted rows to add new column serial Number.
If
I loop in regular way,it gives me all the rows in the table and not the
sorted ones.

try something like...

foreach (DataRowView row in myDataView)
{
row["columnname"] = ...
}

You can also access each row via index...

for (int index = 0; index < myDataView.count; index++)
{
row[index]["columnname"] = ...
}

I'm not sure about the second question. I don't know if a grid typically
pays attention to how a table is sorted once the grid has been bound. It
could be that the grid expects the sorting to happen based on UI events
(e.g. user clicks a column header) once the binding takes place. Hopefully
someone else can answer that for you.

--- HTH, Jeff
 
G

Guest

Hello Jeff,
Thanks a lot for your reply.But the problem is I am using DataViewManager
and not dataview.I am not able to get the dataview for particular table,I am
able to get the DataViewSetting for each table.Here is some code

dsView.DataViewSettings["Personal_Info"].RowFilter =strQuery;
dataGrid1.DataSource = dsView;
dataGrid1.DataMember = "Personal_Info";

Thanks a lot






Jeff B. said:
Q1. I have a dataviewmanager on which I perform some sorts.After sorting,I
need to loop through all the sorted rows to add new column serial Number.
If
I loop in regular way,it gives me all the rows in the table and not the
sorted ones.

try something like...

foreach (DataRowView row in myDataView)
{
row["columnname"] = ...
}

You can also access each row via index...

for (int index = 0; index < myDataView.count; index++)
{
row[index]["columnname"] = ...
}

I'm not sure about the second question. I don't know if a grid typically
pays attention to how a table is sorted once the grid has been bound. It
could be that the grid expects the sorting to happen based on UI events
(e.g. user clicks a column header) once the binding takes place. Hopefully
someone else can answer that for you.

--- HTH, Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top