Hi All,

I am trying to loop through the values of a dataset. Using a 3-tier architecture...so the dataset is created in the BLL. Now i want to retrieve its values and proceed with my desired functionality for each value of the dataset. Can somebody help as I am new to this and don't have much idea about it.

Thanks in advance.

Recommended Answers

All 3 Replies

Try this section of code,basically what it does is this. it gets the DataTable rows inside the dataset(getDataSet) so that you can be able to accsess your desired values.

DataTable myTable = GetDataSet.Tables[0];
	foreach (DataTable DT in GetDataSet.Tables)
	{
		foreach (DataRow in DR myTable.Rows)
		{
			string value1;
			string value2;
			if(condition1==true)
			{
				value1 = DR[1];
				value2 = DR[2];
			}
		}
	}

do you really need that first foreach loop? If you're already getting myTable, just do a foreach on the DataRows in myTable.Rows directly...

You dont actually need it, if you know the actual table name you can actually skip the first foreach loop and go directly to the "DataRows myTable.Rows",its a peference that has helped me adapt to my work situation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.