473,804 Members | 3,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "ItemDataBo und" -- which I belive should
allow me to alter the width of the cells, however it does not work.

Dim unitWidth As Unit
unitWidth.Perce ntage(10)
e.Item.Cells(0) .Width = unitWidth
unitWidth.Perce ntage(80)
e.Item.Cells(1) .Width = unitWidth
unitWidth.Perce ntage(10)
e.Item.Cells(2) .Width = unitWidth
Response.Write( "dgSurveyDates_ ItemDataBound<b r>")
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 "onmouseove r" 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 2152
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.Attribut es["onmouseove r"] = "return myEventHandler( this)";

Eliyahu

"martin" <St************ **@yahoo.com> wrote in message
news:uT******** ******@TK2MSFTN GP10.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 "ItemDataBo und" -- which I belive should
allow me to alter the width of the cells, however it does not work.

Dim unitWidth As Unit
unitWidth.Perce ntage(10)
e.Item.Cells(0) .Width = unitWidth
unitWidth.Perce ntage(80)
e.Item.Cells(1) .Width = unitWidth
unitWidth.Perce ntage(10)
e.Item.Cells(2) .Width = unitWidth
Response.Write( "dgSurveyDates_ ItemDataBound<b r>")
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 "onmouseove r" 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
2527
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. Amazingly I have managed to display the table - no problem, I can select rows - no problem, BUT I can't work out how to display more than one of the fields (now columns in the table in the web page). I can display one field OK, but not more than one...
3
4889
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 the best method? Do you have a sample of how to do this?
8
1965
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 button that inserts a new row in the SQL table and then refresh the datagrid.
4
1229
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, or Ill have to make bit of code on the aspx page... However, I would prefere code in the aspx page at the moment, but it seemed easier to access thecode from codebehind... However... When I run the following code, (when I look at the code it...
5
3638
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. Question: How can I dynamically change the width's of these columns? Thanks in advance.
7
3229
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 column need to be a date picker field. I know things will be easier with ASPX datagrid.
5
1958
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 <asp:Table id="regulatoryDetails" runat="server" Font-Size="X-Small" Width="400px" Height="8px"
6
7998
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, call determined functions, and edit the data already present What will you need to use the grid? A table with standard markup and an ID to call the script that will turn the table into a grid Parameters: tabelaID => id of the table that will...
2
3040
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 length. <html> <head> <title>Rapid Blocking Interface</title> <style> .calendar {
0
9707
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
9585
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10586
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
10338
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...
1
10323
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
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
7622
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...
1
4301
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
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.