-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: Swami_SRS
Message 13 in Discussion
Hi,
The requirement is not so direct. The ways which comes to my mind to implement this
are ...
Method 1. Add an extra column in the datatable.....i will shortly explain how this
meets your requirement.
Method 2. Create a new datatable and add the rows into it.
Of these 2, I prefer the first method over the second method.
Changes reqd. in u'r code..Meth-1
1. Add a dummy column in your datatable. lets name it dummy. Let its default value be
1.
2. ds.Tables["BexAlpha"].DefaultView.RowFilter = "NED = 0 AND RowType = 0";
After you set the rowfilter, loop through all the rows in the default view and set the
value of dummy to 0. (or otherwise too by inverting the wherecls..)
for ...
ds.Tables["BexAlpha"].DefaultView(i)("dummy") = 0
next
3. Now, the datatable will have your 9 rows with a value of 0 and the only other row
with a value of 1. Now remove the rowfilter on the defaultview.
ds.Tables["BexAlpha"].DefaultView.RowFilter = "";
4. Apply the sort in the defaultview with the additional column. i.e if u'r earlier
sortexp is say "Name Asc", then u'r current sort expression should be "Name Asc, Dummy
Asc"
ds.Tables["BexAlpha"].DefaultView.Sort = e.SortExpression + ", Dummy Asc" ;
5. Now bind the default view to the datagrid.
DataGrid1.DataSource =ds.Tables["BexAlpha"].DefaultView; (u get all the 10 rows)
DataGrid1.DataBind();
6. Finally, remove the colm u added. Generally ignoring this step will not create a
prob. but if u have logic based on # of cols then might lead to a situation.
As per the method 2,
1. U have to create a new table.
2. U have to loop through all the records from the defaultview and add every row into
the new table. The row cannot be directly added to the table as it is already a part
of the first table. So you have to make a copy of the rows and then add the row.
3. Then add the additional row which has been eliminated by the defaultview.
4. Bind it to the datagrid.
The reasons i prefer the I method to the second might have been clear now, but still..
1. You do not duplicate the data. Number of Copies of the data is only one.
2. Row copying is not reqd. You manipulate the datatable to get the required sorting.
3. Additional objects are not created.
Hope this helps,
- Swami
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]