如何为asp:repeater提供数据源? [英] how to give a datasource to a asp:repeater?
本文介绍了如何为asp:repeater提供数据源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将数据绑定到数据源到转发器,这是我的代码。对于每个id,我必须从数据库中获取详细信息并使用转发器在页面上显示。
ds只有ds中每个id的id我有从数据库中获取的详细信息。
我的代码中发生的事情只有一条记录被赋予数据源时我超过10个怎么能给所有10个数据源?请帮助。
I want to bind data to datasource to a repeater and this is my code.for each id i have to fetch details from database and show it on page using a repeater.
ds has only id for each id in ds i have fetch details from database.
whats happening in my code is only one record is given a datasource when i more than 10 how can give all 10 to a datasource? Please help.
protected void repeater(DataSet ds)
{
logic.Admin adm = new logic.Admin();
int rowCount = ds.Tables[0].Rows.Count;
DataSet ds1=null;
for (int intCount = 0; intCount < rowCount; intCount++)
{
string id = ds.Tables[0].Rows[intCount]["MUid"].ToString();
ds1 = adm.getUserProfile(Convert.ToInt32(id));
}
MyMentorRep.DataSource = ds1;
MyMentorRep.DataBind();
}
推荐答案
protected void repeater(DataSet ds)
{
logic.Admin adm = new logic.Admin();
int rowCount = ds.Tables[0].Rows.Count;
DataSet ds1=null;
for (int intCount = 0; intCount < ds.Tables[0].Rows.Count; intCount++)
{
string id = ds.Tables[0].Rows[intCount]["MUid"].ToString();
ds1 = adm.getUserProfile(Convert.ToInt32(id));
}
MyMentorRep.DataSource = ds1;
MyMentorRep.DataBind();
}
将所有行添加到从adm.getUserProfile返回的一个表中(Convert.ToInt32(id));然后将该表添加到数据集
然后将数据集分配给转发器作为DataSource
add all the rows to one table returning from adm.getUserProfile(Convert.ToInt32(id)); and then add that table to dataset
then assign dataset to repeater as DataSource
这篇关于如何为asp:repeater提供数据源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文