Click here to Skip to main content
11,478,066 members (70,289 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hi friends,

This is my storedprocedure.
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 28-Dec-12 1:33am

1 solution

Rate this: bad
good
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";
        }
    }
  Permalink  
v3
Comments
baskaran chellasamy at 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 at 28-Dec-12 6:54am
   
hey check now m update my solution 1.. check it and try it..
baskaran chellasamy at 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 at 28-Dec-12 7:03am
   
hey means subject code is static or what??
baskaran chellasamy at 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
0 Sergey Alexandrovich Kryukov 219
1 F-ES Sitecore 170
2 Sascha Lefèvre 170
3 Frankie-C 110
4 OriginalGriff 95
0 Sergey Alexandrovich Kryukov 7,675
1 OriginalGriff 7,321
2 Sascha Lefèvre 3,034
3 Maciej Los 2,491
4 Richard Deeming 2,325


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2015
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