Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

This is my storedprocedure.
SQL
ALTER procedure [dbo].[sp_getmarkforclass](@classid int,@examname varchar(30))
as
begin
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'
execute(@query)
end



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

1 solution

try this.
C#
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";
        }
    }
 
Share this answer
 
v3
Comments
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 change.so 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)



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