C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

For loop


Posted Date: 25 Jun 2009      Posted By: Sachin      Member Level: Gold     Points: 1   Responses: 4



The below value iam getting in the datatable dt

id time status
1 60 60
2 60 5
3 60 60



From this i want to get the id whose timevalue and status value are equal.
For that how i do the coding(in C#)
please tell me the code

By
Vickey..
You must be capable of changing and rearranging your priorities so that your final goal can be achieved.





Responses

Author: satya    25 Jun 2009Member Level: DiamondRating: 1 out of 5     Points: 1

DataTable dt1=(DataTable)Cache["TABLE"];
DataView dv=new DataView(dt1);
string criteria=" Col1 = Col2";
dv.RowFilter=criteria;
DataGrid2.DataSource=dv;
DataGrid2.DataBind();



Author: Narendra Reddy vajrala    25 Jun 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

try like this


foreach (DataRow row in tableTimeStatus.Rows)
{
//Here check condition
if ((row[1].ToString() == entertedTime) && (row[2].ToString() == enteredSatus))
{
//Implement your Functionality
}
}


--Naren
Challenge the Limits, But Don't limit the Challenges.
http://dotnethelpbynaren.blogspot.com/



Author: ABitSmart    25 Jun 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Modified Narendra's code.


List<int> ids = new List<int>();
foreach (DataRow row in tableTimeStatus.Rows)
{
if ((row[1].ToString() == row[2].ToString())
{
ids.Add(row[0].ToString());
}
}



Author: Abhay    25 Jun 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

use for loop compare two columns and if match add to another databale or store in string concate with specialcharacter(as it is number).

Thanks and Regards,
Abhay



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Capture the desktop screen c#.net
Previous : What is ajax
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use