Click here to Skip to main content
15,913,854 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Get table row value inside method ,while in foreach loop

Thanks in advance

Ajith

What I have tried:

C#
dDDate = x;
 duserdata = this.timeattDataSet.data;
 DataRow[] result = duserdata.Select("Date = #" + dDDate + "#");
string  cText_IO="';
foreach (DataRow rows in result)
{
cText_IO = InOutReplace(DateTime dDDate)

}

private static string InOutReplace(DateTime dDDateh)
 // Now I want to get current table column value
    if that value ok return some value

return
Posted
Updated 27-May-17 23:41pm
v2
Comments
Maciej Los 28-May-17 3:00am    
Sorry, but your question is not clear. Can you be more specific and provide more details?
Member 12931315 28-May-17 5:43am    
I am inside foreach loop then I am calling a function going out of loop
once inside function I want to get value of column in current table to
variable ,As I am new c# I don't know right syntax to call current row

Thanks

Ajith

1 solution

Something like this:
foreach (DataRow row in result)
{
	string cText_IO = InOutReplace(row, dDDate)
	Debug.Print(cText_IO);
}
 
private static string InOutReplace(DataRow rowTemp, DateTime dDDateTemp)
{
	if (rowTemp == null)
	{
		return string.Empty;
	}
	
	return rowTemp["Date"].ToString();
}
 
Share this answer
 
Comments
Member 12931315 28-May-17 6:19am    
Yes,It's working
Thank you very much

Ajith

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900