473,626 Members | 3,198 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Format GridView with AutoGenerateCol umns=true

I have a gridview which need to filled by various data according to user's
action. I want to format the dynamical displayed data. For example the number
should be right aligned, datetime column using short format, etc.

Anyway to implement it? Can RowDataBound event do it? Sounds I need to know
the binding columns' data source type (?_ and set the format of the gridview
columns according to the type. Is it possible?
Mar 8 '07 #1
3 7773
You've got to have something there, to be able to format - especially since
you want to have different columns formatted differently - at least you will
need to have boundcolumns, in order to create formatting for each one.

I would think that it might be possible in the rowDatabound event, though
I've never tried it, but you'd need to go by cell number
--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com

"nkw" <nk*@discussion s.microsoft.com wrote in message
news:8B******** *************** ***********@mic rosoft.com...
I have a gridview which need to filled by various data according to user's
action. I want to format the dynamical displayed data. For example the
number
should be right aligned, datetime column using short format, etc.

Anyway to implement it? Can RowDataBound event do it? Sounds I need to
know
the binding columns' data source type (?_ and set the format of the
gridview
columns according to the type. Is it possible?

Mar 8 '07 #2
I cannot bound the columns though. Sounds I need:

1. Capture the column rendering event
2. Get the bound data column type

"David Wier" <da********@noS pamhotmail.comw rote in message
news:#4******** ******@TK2MSFTN GP04.phx.gbl...
You've got to have something there, to be able to format - especially
since
you want to have different columns formatted differently - at least you
will
need to have boundcolumns, in order to create formatting for each one.

I would think that it might be possible in the rowDatabound event, though
I've never tried it, but you'd need to go by cell number
--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com

"nkw" <nk*@discussion s.microsoft.com wrote in message
news:8B******** *************** ***********@mic rosoft.com...
>I have a gridview which need to filled by various data according to
user's
action. I want to format the dynamical displayed data. For example the
number
>should be right aligned, datetime column using short format, etc.

Anyway to implement it? Can RowDataBound event do it? Sounds I need to
know
>the binding columns' data source type (?_ and set the format of the
gridview
>columns according to the type. Is it possible?

Mar 9 '07 #3
You can easily do it in the databound event of the gridview.


"nkw" <nk*@discussion s.microsoft.com wrote in message
news:8B******** *************** ***********@mic rosoft.com...
>I have a gridview which need to filled by various data according to user's
action. I want to format the dynamical displayed data. For example the
number
should be right aligned, datetime column using short format, etc.

Anyway to implement it? Can RowDataBound event do it? Sounds I need to
know
the binding columns' data source type (?_ and set the format of the
gridview
columns according to the type. Is it possible?

Mar 11 '07 #4

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

Similar topics

2
2244
by: Andy Sutorius | last post by:
Can someone point me to an article on how to edit a datagrid when the grid is set to autogeneratecolumns? Each article I have come across has instructions when autogenerate is false and you have an item template with data containers. Thanks Andy
0
1425
by: Sachin | last post by:
Hi All, I am using ASP.NET 2.0 and GridView control. I have a stored procedure, SP_GetAllRows which takes the table name as parameter and fires the query "Select * from TableName" dynamically. My GridView defined like,
1
1884
by: kashif456 | last post by:
I can't figure out why I am getting error updating, deleting and inserting new rows. I am amble to get my dataview populated and also detailview populated: Here's my code: <%@ Page Language=VB CompilationMode=Auto Inherits=CrisisResponseBase %> <script runat="server"> 'Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
3
6929
by: =?Utf-8?B?c2xlbWVu?= | last post by:
Hi, My GridView is bound to a DataTable and the GridView properties are set as follows: AutoGenerateColumns="true" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" The Edit and Detete button are displayed but when the Edit button is clicked, the Update/Cancel buttons are not displayed. Does anyone have any
2
4979
by: BillE | last post by:
I am populating a gridview using auto-generated fields, because I need to enable sorting. I would like to format a column containing dates in the gridview. How is this done? Thanks Bill
10
7955
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I understand how to connect a SqlDataSource to a GridView and have a nice data-connected, paginated web page generated with virtually no coding. Starting from that base, I would like to add an extra column to the GridView and do two things: for each row, based on the value of another column, insert a string in the new column cell and set the background color of the new column cell. Suggested approaches would be appreciated.
2
4842
by: Aamir Ghanchi | last post by:
Hello, I would like to hear if any one else is having the same problem. The AutoGenerateColumns property is set to true. I can read the data right and can loop through the datasource's columnscollection and get the row count, but for some reasons the gridview does not get autopoulated with the results. The Gridview is bound to objectdatasource and I can see all the events firing as follows when I trace: objdsCourseMatrix_Selecting...
4
25522
by: Yin99 | last post by:
I have a Gridview binding to a DataTable source. I'd like to set the column with of the second column. I cannot do this apparently because when AutoGenerateColumns=true, they do not appear in the columns collection. I modified the RowCreated even to gridview, and I can change properties on the cells, but not width. (setting tooltip, background color, etc, all work but changing width has no effect). Here's sample code I am using:
11
2573
by: giveDsolution | last post by:
Hope to find the Solution, My requirment is, I have set AutoGenerateColumns=True for a gridview as i have to add columns at runtime. My first question is: How to hide a column ? And my second question is: Can i add the columns at runtime without doing AutoGenerateColumns=True. Plz Suggest me anykind of alternatives. Thnks in advance
0
8265
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.