473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Change headertext dynamically populated gridview

Hello All,

I have a gridview control in webform which is dynamically populated on
page startup with a query. I was trying to change the header text for
the columns and also set wrap to false. i have four columns in
gridview. Any suggestions guys

This is what i used but i keep getting error
Private Sub changestyle()
GridView1.Columns(1).HeaderText = "First Name"
End Sub

Error
Index was out of range. Must be non-negative and less than the size of
the collection.
Parameter name: index

Dec 1 '06 #1
1 4259
What do you mean by "Dynamically Populated". Do you mean the colums are
automatically generated?

Assuming that's the case, you could just manually declare all the columns
for the gridview instead, rather than relying on the Auto Generate
functionality.

Another possibility is to hook a handler onto Pre-Render of GridView, but
I'm not sure if the Columns will have been generated by then, or even if the
auto-generated columns are accessible in that manner.

"Sharon" <sh**********@yahoo.com.auwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
Hello All,

I have a gridview control in webform which is dynamically populated on
page startup with a query. I was trying to change the header text for
the columns and also set wrap to false. i have four columns in
gridview. Any suggestions guys

This is what i used but i keep getting error
Private Sub changestyle()
GridView1.Columns(1).HeaderText = "First Name"
End Sub

Error
Index was out of range. Must be non-negative and less than the size of
the collection.
Parameter name: index

Dec 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michael via .NET 247 | last post by:
I have a datagrid with the columns defined in the aspx <columns> <asp:TemplateColumn HeaderText="Hours" ItemStyle-Width="1%"ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:TextBox...
3
by: keithb | last post by:
My code dynamically adds template fields to a GridView control. Everything seems to work OK, except when updating, because I haven't found a way to reference the dynamically added textboxes....
3
by: Ashton | last post by:
Hello, I have a GridView; once the page is loaded I can sort it just fine, I can sort it as many times as I would like, I can sort any of the columns. After clicking on Search and the...
1
by: =?Utf-8?B?SGFycnkgS2Vjaw==?= | last post by:
I have a GridView control with a few columns declared directly in the aspx file. I have found that if I remove the HeaderText property from all columns that the GridView handles state completely...
1
by: savajx1 | last post by:
I need to dynamically create a set of bound fields contained in a GridView control. I also have a single static CommandField that I can declare in the Columns <tagof the GridView control. I have...
1
by: Froefel | last post by:
I'm very new to the ADO.NET and WebForms arena, so the problem that I'm having is probably trivial. Using VS2005, I'm just creating a small test project that has a text box allowing you to enter...
1
by: dhaneshrs | last post by:
I have a small code that shows inactive and active users from the ms access DB. <%@ Page Language="VB" MasterPageFile="~/MasterPageAdmin.master" Title="Welcome" %> <%@ Import...
0
by: baburk | last post by:
I am having dropdownlist inside gridview. When the dropdownlist selectedindex change an event should fire. What is the event for his. I also want to get the dropdownlist event fired row...
1
by: Amit00 | last post by:
Hi, I have an ascx file with a gridview, and I need to change the header text of the gridview's column in the code-behind. Something like that: foreach (DataControlField col in GridView1.Columns)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.