Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
SQL
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
Updated 21-Jan-13 15:18pm
v4
Comments
[no name] 22-Jan-13 2:52am    
Do you want it horizontally or vertically.
a2ulthakur 22-Jan-13 3:16am    
horizontally will do

XML
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
 
Share this answer
 
Comments
[no name] 22-Jan-13 3:21am    
Please check if this works or not.
[no name] 22-Jan-13 3:23am    
If possible can you show some screen shots ?
use Datatable.select()

this might make ur work easier...
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900