[英]ObjectDataSource in c# Code Behind?
Is it possible to read the data provided by an ObjectDataSource created in code behind? 是否可以读取由代码隐藏的ObjectDataSource提供的数据? Take the following for instance:
举个例子:
ObjectDataSource myObjectDataSource= new ObjectDataSource();
myObjectDataSource.SelectParameters.Add(new SessionParameter("createdDate", TypeCode.String, "FilterCreated"));
How could you then get the rows from this? 你怎么能从这里得到行? For example in a Dataset you would do something like:
例如,在数据集中,您可以执行以下操作:
foreach (DataRow dr in myDataset.Tables[0].Rows) {
string abc = dr["myColumn"];
}
you can try like this , convert objectdatasource to dataset and than read that 你可以尝试这样,将objectdatasource转换为数据集,而不是读取它
private DataSet ConvertObjectSourceToDataSet(ObjectDataSource ods)
{
var ds = new DataSet();
var dv = (DataView)ods.Select();
if (dv != null && dv.Count > 0)
{
var dt = dv.ToTable();
ds.Tables.Add(dt);
}
return ds;
}
Code source : http://www.aspdotnet-suresh.com/2010/09/how-to-bind-dataset-with.html 代码来源: http : //www.aspdotnet-suresh.com/2010/09/how-to-bind-dataset-with.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.