TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
kaurm
NA
12
14k
how to change Gridview header text of columns using SQL valu
Jan 14 2014 6:08 PM
I'm making a C# asp.net webpage that shows the data for certain items but I want to set the header's values in gridview so it will change the text depending on what item the user is viewing.
For example: the user wants to see data for Object A than it should go into the database find what values the table should show for the header for this item.
So if in the database it says: size, height, material than those three would be the headers text.
But if it's Object B than it should show the header text as following: size, length, color.
Each item would have different text for the header depending on what the user picks.
I already have the part done where it's getting the values from the database. I'm having trouble on how to make the header dynamic using the header names from the database.
I saw this method that can be used in .cs page but it's not dynamic.
protected
void
GridView1_RowDataBound
(
object
sender
,
GridViewRowEventArgs
e
)
{
if
(
e
.
Row
.
RowType
==
DataControlRowType
.
Header
)
{
e
.
Row
.
Cells
[
0
].
Text
=
"The new header"
;
}
}
How can I get the values I'm reading from the sql commands and relate it to the header? I just can't find the right syntax or method to relate them.
Reply
Answers (
2
)
Generate pdf with FOP issue
How to look up values from database using multiple tables