Click here to Skip to main content
12,350,735 members (24,693 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server
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 22-Jan-13 2:52am
   
Do you want it horizontally or vertically.
a2ulthakur 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 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
 
good
Please Sign up or sign in to vote.

Solution 1

use Datatable.select()

this might make ur work easier...
  Permalink  
Comments
a2ulthakur 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 | Mobile
Web01 | 2.8.160621.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2016
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