DataSourceSelectArguments args = new DataSourceSelectArguments();
dv = SqlDataSource1.Select(args) as DataView;
dt = dv.ToTable() as DataTable;
foreach(DataRow myRow in dt.Rows)
{
foreach(DataColumn myCol in dt.Columns)
{
Console.WriteLine(myRow[myCol]);
}
}
Please post your code for us to help!!
Mark Answered if it helps - Good luck!
Cheers!
Design And Align - Rob
Marked as answer by GrassProgrammer on Jun 12, 2012 05:52 PM
GrassProgram...
Member
369 Points
257 Posts
How to access SqlDataSource data from C# code?
Jun 12, 2012 05:33 PM|LINK
I have an SqlDataSource. How can I access its columns/rows from within my C# code?
tinmgaye
Member
430 Points
80 Posts
Re: How to access SqlDataSource data from C# code?
Jun 12, 2012 05:41 PM|LINK
Please refer to its API reference http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.aspx
robwscott
Star
8079 Points
1491 Posts
Re: How to access SqlDataSource data from C# code?
Jun 12, 2012 05:42 PM|LINK
DataSourceSelectArguments args = new DataSourceSelectArguments(); dv = SqlDataSource1.Select(args) as DataView; dt = dv.ToTable() as DataTable; foreach(DataRow myRow in dt.Rows) { foreach(DataColumn myCol in dt.Columns) { Console.WriteLine(myRow[myCol]); } }Mark Answered if it helps - Good luck!
Cheers!
Design And Align
- Rob
Charlie3D
Member
2 Points
1 Post
Re: How to access SqlDataSource data from C# code?
Dec 18, 2012 10:40 AM|LINK
We do not have to instantiate DataSourceSelectArguments class. The following fragment is more efficient: