|
Currently I have a datarow that I need to itterate through, of which I have decided to use a foreach loop to retrieve my values. The trick is, I need to get the next row of values from the current row.
Any help would be appreciatied.
Thanks
|
|
|
|
|
int numRows = myDataTable.Rows.Count;
for(int i=0; i<numRows-1;i++)
{
DataRow currentRow = myDataTable.Rows[i];
DataRow nextRow = myDataTable.Rows[i+1];
}
|
|
|
|
|
Had it working that way, just curious if there was a way to do it with the foreach loop.
Thanks
|
|
|
|
|
avanwieren wrote: just curious if there was a way to do it with the foreach loop.
Yes, but it is more complex
|
|
|
|
|
how about:
foreach (DataRow row in myDataTable.Rows) {...}
Luc Pattyn
|
|
|
|
|
Luc Pattyn wrote: foreach (DataRow row in myDataTable.Rows) {...}
No, because he wants to access the current row and NEXT row as the same time.
|
|
|
|
|
Three ways to have access at two rows at once:
DataRow previousRow=null;
foreach (DataRow row in myDataTable.Rows) {
previousRow=row;
}
or (problem here is to get an appropriate dummy data row outside the data set)
DataRow previousRow=aDummyDataRow;
foreach (DataRow row in myDataTable.Rows) {
previousRow=row;
}
or (only when DataSet extended with a dummy head row):
DataRow previousRow=null;
foreach (DataRow row in myDataTable.Rows) {
if (previousRow!=null) {
}
previousRow=row;
}
Luc Pattyn
|
|
|
|
|
True, but all of these require slightly more complex logic that the simple for(int i=0....) style that I gave here[^]. I'd rather have something that had simpler logic and was easier to read and understand.
|
|
|
|
|
Colin Angus Mackay wrote: I'd rather have something that had simpler logic and was easier to read and understand.
I agree completely, I tried to give a solution to the foreach question anyway.
Luc Pattyn
|
|
|
|
|
Hello All,
I was just wondering if anyone knew how to disable the sorting on data grid columns. I don't want my end users to click the column headers and sort the data. Is there a proerty to set? Any help would be greatly appreciated.
|
|
|
|
|
Set the SortMode property to DataGridViewColumnSortMode.NotSortable.
|
|
|
|
|
Thanks but where is this sort mode propery? I can't find on datagridview control.
|
|
|
|
|
DataGridViewColumn.SortMode
Note: This property is new in the .NET Framework version 2.0.
Luc Pattyn
|
|
|
|
|
hi
how to doing setup project my application in c# to use or inistiler in any computer dont have .net
and sorry for bad english eriting.
thank you for help me
|
|
|
|
|
|
hi all,
I need to develop a service application that runs on a server. This application is used to get some data from the database and according to this data sends mails to clients and to the administrator. This service application is needed to run every morning at 9:00 A.M. and only once per day.
It it the first time that i deal with service application. So i have no experience in it. I made some search on the codeproject and i came up with some good result that helped me get some idea.
one of the problems i faced is that i can not add a data source to it.
can any body help me
thanks
|
|
|
|
|
Hi,
Need a simple create table script for SQL server 2007.
Here's the structure:
Column1: primary key, integer, auto increment
Column2: Name, char, length 100, not null
Column3: address, char length 200, not null
Please help
ASP - AJAX is SEXY. PERIOD.
|
|
|
|
|
Bulky Fellow wrote: SQL server 2007.
No such product. Did you mean SQL Server 2005?
CREATE TABLE dbo.SomeTableName
(
SomeColumnName INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,
Name CHAR(100) NOT NULL,
address CHAR(200) NOT NULL
);
May I recomment that you use VARCHAR instead of the CHAR type that you requested.
|
|
|
|
|
|
Thanks a lot for your help!
And by the way, I meant SQL server 2000. Made a mistake there.
ASP - AJAX is SEXY. PERIOD.
|
|
|
|
|
How to lock folders.
Help.
Vasildb
|
|
|
|
|
What are you trying to do? You may want to be more articulate.
|
|
|
|
|
I think he might mean that he wants to lock a folder in the same way that Windows prevents you from looking in System folders.
---
Sup!
|
|
|
|
|
Yes. Do not view or can not open.
Vasildb
|
|
|
|
|
Hi,
Iam Mahender. Can anyone Plz tell me How remove session in my web-application. My web application consists of Report viewer control. Can u tell me How to write a class that implements IReportserverconnection. I wrote Class that implements IReportserverconnection Interface , implemented all Properties and Method.( I took Guidance from .(taking Guidance 4m (http://msdn2.microsoft.com/en-us/library/microsoft.reporting.webforms.ireportserverconnection2(VS.80).aspx).For the First time When Page loads, Upon Clicking a Button, a Report gets Loaded Successfully, When I select second page of Report or try to export Report to XML(Or Other Formats) I try to get exception as
“The source of the report definition has not been specified".”.
I request anyone to Plz tell me solution for this problem……….
Waiting for ur Replies……
With Regards,
S.N.P.C Mahender,
mhi
|
|
|
|