Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用C#和SQL在asp.net的repeater控件中显示列的总计_C#_Sql_Asp.net - Fatal编程技术网

如何使用C#和SQL在asp.net的repeater控件中显示列的总计

如何使用C#和SQL在asp.net的repeater控件中显示列的总计,c#,sql,asp.net,C#,Sql,Asp.net,我是asp.net的初学者,因此我正在开发一个软件,其中我想对总价列进行汇总,例如,我在总价列中有1,2,3(这些值来自SQL数据库)值,我想对这些值进行汇总(汇总后的结果是6)并在repeater控件的页脚模板中显示此列的总计。如果有人告诉我,我非常感激 谢谢 我猜你把这个答案贴错问题了?实际上与OP的问题没有任何关系(加上这个问题,因为它没有代码,只是一个一般性的要求,所以写出来的问题是离题的)。另外,在将来,请在你的答案中添加文本,解释他们如何回答问题,而不是仅仅一段代码。 in

我是asp.net的初学者,因此我正在开发一个软件,其中我想对总价列进行汇总,例如,我在总价列中有1,2,3(这些值来自SQL数据库)值,我想对这些值进行汇总(汇总后的结果是6)并在repeater控件的页脚模板中显示此列的总计。如果有人告诉我,我非常感激


谢谢

我猜你把这个答案贴错问题了?实际上与OP的问题没有任何关系(加上这个问题,因为它没有代码,只是一个一般性的要求,所以写出来的问题是离题的)。另外,在将来,请在你的答案中添加文本,解释他们如何回答问题,而不是仅仅一段代码。
     int total = 0;
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item)
        {
            //using findcontrol method the label and get the amount
            total += Convert.ToInt32(((Label)e.Item.FindControl("ltrlAmount")).Text);
             
            //
        }
        else if (e.Item.ItemType == ListItemType.Footer)
        {
            Label lbl = (Label)e.Item.FindControl("Label1");
            lbl.Text = total.toString(); //set value
        }
    }