Re: Datagrid table cells and rows -- Changing width

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Eliyahu Goldin (removemeegoldin_at_monarchmed.com)
Date: 06/09/04


Date: Wed, 9 Jun 2004 10:40:46 +0200

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" <Stuart_REMOVE_36@yahoo.com> wrote in message
news:uTBhUabTEHA.2544@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.
>
>



Relevant Pages

  • RE: How to put different cell type in the same DataGrid column?
    ... DataGridColumnStyle paints the cell contents internally. ... checkboxes, DataGridBoolColumn.Paint method draws the dummy CheckBoxes. ... Whenever the end user clicked certain cell in DataGrid, ... method will show an internal Control and move to that cell rectangle. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Cannot set datagrid Text attribute ????
    ... serge try using template columns in your datagrid and use a control with an ... Use findcontrol to get the ID of the control in the itemtemplate in the ... I have a datagrid which is bind to a databse table. ... At this time the cell backcolor is properly set according to the database ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Error while writing Excel automation solution.
    ... double-click of it will insert the content to the selected cell. ... i required datagrid which is giving me error. ... >> calling from a custom menu in the excel. ... >> I am getting runtime error when the form comes up with a datagrid control ...
    (microsoft.public.vsnet.vstools.office)
  • RE: How to Fix Columns width?
    ... you do databinding paging for your DataGrid ... this is because some the Text in the DataGrid table cell has ... to do with DataGrid server control. ... you may specify a column width value that is ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Re: How retrieve width of a cell?
    ... do you want to retrive "Width" of the Cell which is calculated by the users ... value in the column template in the datagrid then i think you should retrive ... Prev by Date: ...
    (microsoft.public.dotnet.framework.aspnet)