Click here to Skip to main content
12,763,750 members (35,443 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# C#4.0
Hi friends,

This is my storedprocedure.
ALTER procedure [dbo].[sp_getmarkforclass](@classid int,@examname varchar(30))
declare @paramlist varchar(max),@query nvarchar(max),@examid int
select @examid=ExamId from ExamNameSetting_details where ExamName=@examname
set @paramlist=STUFF((select distinct ',[' + SubjectId + ']' from School.dbo.Mark_details where classid=@classid and ExamId=@examid for xml path('')),1,1,'')
set @query=N'select * from(select sc.RollNumber,sa.StudnetAdmissionNumber,sb.StudentName,sa.SubjectId,sa.MarkObtained from School.dbo.Mark_details sa inner join School.dbo.StudentAdmission_details sb on sa.StudnetAdmissionNumber=sb.AdmissionNumber inner join StudentRollNumberAllocation_details sc on sb.AdmissionNumber=sc.AdmissionNumber ) p PIVOT(Max(MarkObtained)for SubjectId IN ('+@paramlist+')) AS pvt'

and this is my output

RollNumber	adnumberStudentName	23011	23012	23013	23014	23015
12130100	103	divya	        77      88      77	77	66
12130101	102	Gayathiri	77	88	99	99	77
12130102	100	Chandru		77	88	99	88      88

and I want that columnheader as Tamil for 23011, english for23012, maths for 23013 and likewise. this 23011 and follows are subjectid for subjectname of tamil and follows on the subjectname table. how can change the columnName when load to datagrid.
Posted 28-Dec-12 1:33am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

try this.
protected void gdvUsuarios_RowDataBound(object sender, GridViewRowEventArgs e)
        if (e.Row.RowType == DataControlRowType.Header)
           if(e.Row.Cells[3].Text == "23011") 
                e.Row.Cells[3].Text = "Tamil";          
           if(e.Row.Cells[4].Text == "23012")            
                e.Row.Cells[4].Text = "english";          
           if(e.Row.Cells[5].Text == "23013") 
                e.Row.Cells[5].Text = "maths";          
           if(e.Row.Cells[6].Text == "23014") 
                e.Row.Cells[6].Text = "Geography";          
           if(e.Row.Cells[7].Text == "23015") 
                e.Row.Cells[7].Text = "History";
baskaran chellasamy 28-Dec-12 6:48am
actually subject name could be changed dynamically for classwise. so i cannot set this one as a static.
prashant patil 4987 28-Dec-12 6:54am
hey check now m update my solution 1.. check it and try it..
baskaran chellasamy 28-Dec-12 7:00am
thank you friends. but still it is static. because some time for classes no of subject to be change and name of the subject also will that i want to get subjectname for a particular class from sql server table. In there I set how many subject for per class and subject name also. so i want to get subjectname at run time
prashant patil 4987 28-Dec-12 7:03am
hey means subject code is static or what??
baskaran chellasamy 28-Dec-12 7:07am
subject code is not static for all class. it is different for each class

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
Web02 | 2.8.170217.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2017
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