本文介绍了将数据集结果,赔率和均值分割为相应的中继器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将数据集分成两个中继器,左转发器的几率,右转发器的均衡。我的代码目前只是将两者分开,但我需要赔率为一方而另一方。这是我的代码。提前谢谢!
im trying to split a dataset over two repeaters, odds to left repeater, evens to right repeater. my code at the moment just divides the two, but i need odds to be one side and evens the other. here is my code. thanks in advance!
DataView pageToView = (DataView)pagedRequests.DataSource;
DataTable leftContent = pageToView.Table.Clone();
int divide = pagedRequests.Count / 2;
for (int i = 0; i < divide; i++)
{
leftContent.ImportRow(pageToView.Table.Rows[i + pagedRequests.FirstIndexInPage]);
}
DataTable rightContent = pageToView.Table.Clone();
for (int i = divide; i < pagedRequests.Count; i++)
{
rightContent.ImportRow(pageToView.Table.Rows[i + pagedRequests.FirstIndexInPage]);
}
favRepeaterLeft.DataSource = leftContent;
favRepeaterLeft.DataBind();
favRepeaterRight.DataSource = rightContent;
favRepeaterRight.DataBind();
推荐答案
for(int i = 0; i < pagedRequests.Count; i++)
{
if(i == 0 || i % 2 == 0) //even
{
rightContent.ImportRow(pageToView.Table.Rows[i + pagedRequests.FirstIndexInPage]);
}
else //odd
{
leftContent.ImportRow(pageToView.Table.Rows[i + pagedRequests.FirstIndexInPage]);
}
}
这篇关于将数据集结果,赔率和均值分割为相应的中继器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!