本文介绍了gridview在页脚中添加列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将数据添加到页脚中的单个单元格中.如何绑定数据请帮助我.
i want to add a data to a single cell in footer. how to bind that data plz help me.
SqlDataAdapter add = new SqlDataAdapter("select sum(Total) from tblQuotationreg",con);
DataTable dt = new DataTable();
add.Fill(dt);
GridView1.DataSource = dt;
GridView1.Columns[6].FooterText.DataBind();
这是我尝试在gidview中有6列和页脚的代码,我想添加总数并将其显示在我的页脚中,尤其是在第6列中.
这是运行上面的代码时发生的错误::
this is the code i tried im having 6 columns and footer in my gidview i want to add the total and display it in my footer particularly in my column 6.
This is the error occur while running the above code::
'string' does not contain a definition for 'DataBind' and no extension method 'DataBind' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)
推荐答案
hi ,
use this it will help .
<FooterTemplate>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</FooterTemplate>
Label lb = ((Label)GridView1.FooterRow.FindControl("Label2")); ;
lb.Text = "123";
这篇关于gridview在页脚中添加列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!