Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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

 
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
Edited 21-Jan-13 15:18pm
v4
Comments
onurag19 at 22-Jan-13 2:52am
   
Do you want it horizontally or vertically.
a2ulthakur at 22-Jan-13 3:16am
   
horizontally will do
Rate this: bad
good
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">
 
<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
  Permalink  
Comments
onurag19 at 22-Jan-13 3:21am
   
Please check if this works or not.
onurag19 at 22-Jan-13 3:23am
   
If possible can you show some screen shots ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

use Datatable.select()
 
this might make ur work easier...
  Permalink  
Comments
a2ulthakur at 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
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 350
1 Sergey Alexandrovich Kryukov 226
2 Shai Vashdi 220
3 OriginalGriff 183
4 Tadit Dash 135
0 Sergey Alexandrovich Kryukov 9,255
1 OriginalGriff 5,433
2 Peter Leow 4,100
3 Maciej Los 3,540
4 Abhinav S 3,333


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid