我有一个名为预算的网格视图,我希望逐年显示数据? [英] i have a gridview called budget in which i want to show data yearwise ?

查看:48
本文介绍了我有一个名为预算的网格视图,我希望逐年显示数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT     m.pcode, m.fyyear, m.date, m.salary, m.ta, m.contigency, m.nrc, m.institcharges, m.others, p.total, y.yearlyalloc
FROM         monthly AS m INNER JOIN
                      project AS p ON p.pcode = m.pcode INNER JOIN
                      yearly AS y ON y.pcode = m.pcode





这是我的SQL查询,我想显示年度分配(annualalloc)根据财政年度(fyyear)。这意味着我的专栏pcode,date,salary,ta,contingency,nrc,institcharges,others,annualalloc应该根据财政年度显示。基本上我想根据财政年度对它们进行分组,但我的只有两张表包含了fyyear。

例如:在我的gridview中我想显示这样的数据



pcode fyyear date salary ta contigency nrc instit ..yearlalloc

adhoc 110 2010-2011 03/04/2010 16000 1000 120 0 0 120000







adhoc 110 2011-2012 03/04/2011 16000 1000 120 0 0 180000



我使用的代码仅绑定两个表格我必须根据fyyear(财政年度)plz帮助从年度和组数据插入y.yearlyalloc查询



this is my sql query, i want to display yearly allocation(yearlyalloc) according financial year(fyyear). which means my columns pcode,date,salary,ta,contingency,nrc,institcharges,others,yearlyalloc should be shown according to financial year. basically i want to group them according to financial years, but only two tables of mine contain fyyear.
eg: in my gridview i want to display data like this

pcode fyyear date salary ta contigency nrc instit ..yearlalloc
adhoc 110 2010-2011 03/04/2010 16000 1000 120 0 0 120000
.
.
.
adhoc 110 2011-2012 03/04/2011 16000 1000 120 0 0 180000

the code behind that i am using only binds two tables and i have to insert y.yearlyalloc from yearly and group data according to fyyear(financial year) plz help with the query

推荐答案

You can make use of the DataList Control instead of the GridView Control. Make sure u specify the RepeatDirection as horizontal.

<asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal">

<ItemTemplate>

<asp:Label ID="label1" runat="server" Text='<%# Eval("colomn_name")+ " " %>'></asp:Label>

</ItemTemplate>

</asp:DataList>

and the cs code would be as follows:

SqlConnection connection = new SqlConnection("Integrated Security=true; Initial Catalog=server_name; Data Source=database_name");

protected void Page_Load(object sender, EventArgs e)

{
if (!IsPostBack)

{

SqlCommand command = new SqlCommand("select colomn_name from table_name order by your_id", connection);
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable dtEmployees = new DataTable();

adapter.Fill(dtEmployees);

DataList1.DataSource = dtEmployees;

DataList1.DataBind();

}

}

It may help you


使用Datatable.select( )



这可能会让你的工作更轻松......
use Datatable.select()

this might make ur work easier...


这篇关于我有一个名为预算的网格视图,我希望逐年显示数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆