|
-
Mar 5th, 2009, 03:01 PM
#1
Thread Starter
Member
Dynamically formatting a GridView in ASP.net using C# 2005
I am creating a website using ASP.net with C# 2005 as the language.
In my ASP.net page, I have displayed a GridView. I have dynamically populated the GridView during runtime using Dataset and SQLDataAdapter.
Since the GridView displays ALL columns at a fixed width, it does not look pretty to me (even after applying AutoFormat style). I need to hide a few columns, change the width of a few columns and change the heading of ALL columns. I know, I can solve the first requirement of displaying only selected columns by using a Select statement with the required fieldnames only (as against Select *), but I do not know how to change the Column width and change the Column header.
I tried using the syntax like,
GridView1.Columns[0].visible = false;
GridView1.Columns[1].ItemStyle.Width = 50;
GridView1.Columns[2].HeaderText = "Result Time";
but it gave me error messages like "index was out of range".
Can anybody please help me?
Thank you.
Lalit Kumar Barik
India
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|