Click here to Skip to main content
13,549,148 members
Rate this:
Please Sign up or sign in to vote.
SELECT     m.pcode, m.fyyear,, m.salary, m.ta, m.contigency, m.nrc, m.institcharges, m.others,, 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

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
Posted 19-Jan-13 16:55pm
Updated 21-Jan-13 15:18pm
onurag19 22-Jan-13 2:52am
Do you want it horizontally or vertically.
a2ul 22-Jan-13 3:16am
horizontally will do
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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">


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



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();


DataList1.DataSource = dtEmployees;




It may help you
onurag19 22-Jan-13 3:21am
Please check if this works or not.
onurag19 22-Jan-13 3:23am
If possible can you show some screen shots ?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


this might make ur work easier...
a2ul 20-Jan-13 7:47am
can u be more clear ..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180515.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100