开发者

Using the selected items in Sqldatasource

开发者 https://www.devze.com 2023-01-08 14:46 出处:网络
How can I use the results开发者_如何学编程 of the select method in SqlDatasource like assign the returned id to a variable ?By default the SqlDataSource returns a System.Data.DataView object from its

How can I use the results开发者_如何学编程 of the select method in SqlDatasource like assign the returned id to a variable ?


By default the SqlDataSource returns a System.Data.DataView object from its select method:

System.Web.UI.WebControls.SqlDataSource source = new System.Web.UI.WebControls.SqlDataSource("Connection String", "Select Query");
System.Data.DataView view = (System.Data.DataView)source.Select(System.Web.UI.DataSourceSelectArguments.Empty);

The System.Data.DataView object is a collection of System.Data.DataRowView so if you wanted to get the value of "pk" column for the first object you do this:

int itemIndex = 0;
String ColumnName = "pk";
int ID = view[itemIndex][ColumnName];
0

精彩评论

暂无评论...
验证码 换一张
取 消