使用for循环绑定转发器以从数据库中检索多个值

时间:2013-04-03 09:58:54

标签: asp.net c#-4.0

这个我的代码我想从数据库中获取值并在转发器中插入此代码只返回数据库中的最后一个值

for (int i = 0; i < dtFinalVessel.Rows.Count; i++)          
    if (i == 0)
    {
        if (e.Item.ItemType == ListItemType.Item)
        {

            DataTable dtCostElement = DAL.MonthlyCrudeAccrualsDetail.GetMonthlyCrudeAccrualsPerFinalBolID_Get_List(int.Parse(dtFinalVessel.Rows[0]["FinalVesselPerBOLID"].ToString()));

            ArrayList arrlist = new ArrayList();

            Repeater rptrCostElementHeader = (Repeater)e.Item.FindControl("rptrCostElementHeader");
            rptrCostElementHeader.DataSource = dtCostElement;
            rptrCostElementHeader.DataBind();

            Repeater rptrUS = (Repeater)e.Item.FindControl("rptrUS");
            rptrUS.DataSource = dtCostElement;
            rptrUS.DataBind();

            Repeater rptrZAR = (Repeater)e.Item.FindControl("rptrZAR");
            rptrZAR.DataSource = dtCostElement;
            rptrZAR.DataBind();


            Repeater rptrUSCent = (Repeater)e.Item.FindControl("rptrUSCent");
            rptrUSCent.DataSource = dtCostElement;
            rptrUSCent.DataBind();

            for (int j = 0; j < dtCostElement.Rows.Count; j++)
            {
                string strUscent = dtCostElement.Rows[j]["USCent"].ToString();
                decimal total = decimal.Parse(strUscent.ToString()) / decimal.Parse(hdnTotalVessel.Value.ToString());
                arrlist.Add(total.ToString());
            }
            Repeater rptAvgUSCent = (Repeater)e.Item.FindControl("rptAvgUSCent");
            rptAvgUSCent.DataSource = arrlist;
            rptAvgUSCent.DataBind();`


        }
    }     
}

0 个答案:

没有答案