baskaran chellasamy

baskaran chellasamy

  • NA
  • 114
  • 150.5k

how can change the datagridcolumnheadername at runtime

Dec 31 2012 5:36 AM
hello Friends

  The following is my stored procedure
 
 
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 the output of this query is


RollNumber  adnumber StudentName 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

I get this value by using datatable for binding datagridview. but before i want to bind i need to change the column header name as Tamil for 23011 and English for 23012 and follows.but it is not a static for every class. when i get data for different class ,it get different subjectcode and based on the code i want to bind subject name.subject code and name available in subject table.
how can do that.  

Answers (2)