Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Customize a Gridview

I've created a Gridview and i'm populating it with data from my database. However the width of the columns changes depending on what data is in the cell. I've tried setting the individual columns ItemStyle and setting the width but it only seems to effect how the gridview in design view and not when the application is running.

Is there a property or something I can set that will make the rows single line as appose to multi-line and keep a constant width of the columns?

thanks,

Adrian.
[531 byte] By [admol] at [2007-11-11 10:26:17]
# 1 Re: Customize a Gridview
The Gridview has AutoSizeColumnsMode and AutoSizeRowsMode properties. Don't these do what you need?
joewmaki at 2007-11-11 23:11:51 >
# 2 Re: Customize a Gridview
I've read that they are but i do not know how to set them. There are not in the gridview properties or anywhere else i've looked.

Any ideas?
admol at 2007-11-11 23:12:51 >
# 3 Re: Customize a Gridview
Is this a webform?
Windows forms have these properties available (under Layout Category). Are you using VS2005?
joewmaki at 2007-11-11 23:13:50 >
# 4 Re: Customize a Gridview
Ya its a web site and i'm using VS2005. I can't see Layout Category under the properties of my gridview
admol at 2007-11-11 23:14:49 >
# 5 Re: Customize a Gridview
Sorry, it doesn't appear to be a property of the web control.
joewmaki at 2007-11-11 23:15:59 >
# 6 Re: Customize a Gridview
I still havn't fixed my problem.

Any help would be great appreciated.

Thanks,

Adrian.
admol at 2007-11-11 23:16:58 >
# 7 Re: Customize a Gridview
Adrain, can we define just what your trying to do. It sounds as if you want fixed column widths and rows to be restricted to a single row height, correct? My understanding is the rows are wrapping now because you have more data than the column width can display, correct?
How would you want this to work?
joewmaki at 2007-11-11 23:17:58 >
# 8 Re: Customize a Gridview
Hi

I think you should view this article, it will solve your problem, sometimes setting width is not a solution and you dont want to wrap the text either.

View this article hopefully you will solve your problem

http://www.dev-archive.com/codemag/Article/17440/0/page/3
zubinkasad at 2007-11-11 23:19:01 >