473,394 Members | 1,740 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,394 software developers and data experts.

Datagrid table cells and rows -- Changing width

Hi,

I have a datagrid that contains 3 colums. This is rendered to the page fine,
except that I would like to be able to control the width of each table cell
of the datagrid
I have the following code in the "ItemDataBound" -- which I belive should
allow me to alter the width of the cells, however it does not work.

Dim unitWidth As Unit
unitWidth.Percentage(10)
e.Item.Cells(0).Width = unitWidth
unitWidth.Percentage(80)
e.Item.Cells(1).Width = unitWidth
unitWidth.Percentage(10)
e.Item.Cells(2).Width = unitWidth
Response.Write("dgSurveyDates_ItemDataBound<br>")
After this I tried placing the width attribute into the HTML of the
datagrid, however that gave a runtime error.

can anybody explain how to do this please.. I would also like to add client
side events such as "onmouseover" to the <tr> tag of each row, but I can't
seem to be able to do this either..

any help or advice would be appreciated.

thanks in advance.

martin.
Nov 18 '05 #1
1 2128
Martin,

You don't have full control over column width. The browser considers your
width instructions as recommendations. You can trick it a bit though. One of
the tricks I am using is setting the width to 1px for a column that I want
to be as narrow as possible. Then the browser will set the width of this
column to the width of the longest word. You can use non-breaking spaces to
join several words into one.

Setting cell width for every row separately, as in your example, doesn't
make much sence since all cells in one column have to have the same width.

The following C# code adds onmouseover event to the row:
e.Item.Attributes["onmouseover"] = "return myEventHandler(this)";

Eliyahu

"martin" <St**************@yahoo.com> wrote in message
news:uT**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a datagrid that contains 3 colums. This is rendered to the page fine, except that I would like to be able to control the width of each table cell of the datagrid
I have the following code in the "ItemDataBound" -- which I belive should
allow me to alter the width of the cells, however it does not work.

Dim unitWidth As Unit
unitWidth.Percentage(10)
e.Item.Cells(0).Width = unitWidth
unitWidth.Percentage(80)
e.Item.Cells(1).Width = unitWidth
unitWidth.Percentage(10)
e.Item.Cells(2).Width = unitWidth
Response.Write("dgSurveyDates_ItemDataBound<br>")
After this I tried placing the width attribute into the HTML of the
datagrid, however that gave a runtime error.

can anybody explain how to do this please.. I would also like to add client side events such as "onmouseover" to the <tr> tag of each row, but I can't
seem to be able to do this either..

any help or advice would be appreciated.

thanks in advance.

martin.

Nov 18 '05 #2

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

Similar topics

1
by: Joe Bloggs | last post by:
I am trying display the contents of a table in a web page, select certain rows from that table and then display the fields that I have selected (now table columns) as text in a Label object....
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
8
by: Inigo Jimenez | last post by:
I have an ASP .net web application installed in a Windows 2003 server. This web application has a webform that has a Datagrid. This Datagrid is filled with the data of a SQL table. I have a...
4
by: Kristoffer Arfvidson | last post by:
Im trying to get access to a table in codebehind, because the information in this table is different depending on what it says in the database... So, either I have to access it from codebehind,...
5
by: VB Programmer | last post by:
I have a simple datagrid on a webform. (I'm using VB.NET.) In the page load I get some data, set the .DataSource property of the dg, then do a .DataBind. The columns are automatically created. ...
7
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the...
5
by: vpravin | last post by:
Hi guys...i am a super noob with html and aspx.. i didnt start this project but i am modifying it... q: how do i change the width of a column: Thats the table which is within a text box ...
6
by: Romulo NF | last post by:
Greetings again to everyone, Im back to show this grid componenet i´ve developed. With this grid you can show the data like a normal table, remove the rows that you need, add rows, import data,...
2
by: markszlazak | last post by:
I'm a relatively slow response of table cells changing their background color with mouseover/our in IE6 (Win 2K) but the response is fine (fast) in Firefox. Why? The code is below. Sorry about the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.