Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Mad Scientist Jr #1
problem sizing columns in datagrid
I have a datagrid that has a column that I would like to be the widest
(say 60%) - however another column is populated with some data that is
sometimes a rather long string, and it expands to take up most of the
table width. I tried to force the column sizes to force the longer
column to wrap but it isn't working. Any help appreciated, my code is
below:
DataGrid1.DataSource = DataTable1
DataGrid1.DataBind()
DataGrid1.Columns(0).ItemStyle.Width = Unit.Percentage(10)
DataGrid1.Columns(1).ItemStyle.Width = Unit.Percentage(60)
' this column is getting squashed
DataGrid1.Columns(2).ItemStyle.Width = Unit.Percentage(10)
' this column still ends up taking 70% or so
DataGrid1.Columns(3).ItemStyle.Width = Unit.Percentage(10)
Mad Scientist Jr Guest
-
Sizing text entry boxes on in-place editing of datagrid row with dynamically created columns
Built a datagrid with dynamically created bound columns, andadded editing in-place, deletions and add-new features that workfine. One minor detail... -
Sizing the dataGrid
I have a dataGrid on a form, In design mode it behaves as I would expect when resizing the form. However when I populate it when running, it no... -
Problem Hiding Columns when Populating a Datagrid with a DataView of A DataTable From Dataset returned via an Asynchronous Web-Service
Hi I have a webservice that retrieves data from a database, this is then returned to the calling client application built in windows forms within... -
Autogenerated Datagrid columns rebinding problem on postback
Just to give a brief background what I'm trying to do, is I have a DataGrid with 2 static columns, and the rest are autogenerated (which have... -
Columns and Inherited Datagrid...Active Schema does not support columns
I have a class which has inherited from datagrid, to provide some custom functionality, row select, mouse overs etc All is working fine apart from... -
anon #2
Re: problem sizing columns in datagrid
One solution is to check the length of this particular column that is
causing wider columns in itemdatabound....
string d = Convert.ToString(DataBinder.Eval(e.Item.DataItem,. ...));
if (d.Length > 50)
{
Label lb = (Label) e.Item.FindControl("lb");
lb.Text = d.Substring(0, 45) + "...";
}
Hope that helps,
Ben
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
anon Guest
-
Mad Scientist Jr #3
Re: problem sizing columns in datagrid
actually that's not a bad idea... thanks for responding
Mad Scientist Jr Guest
-
Mike Hutton #4
Re: problem sizing columns in datagrid
anon <anonymous@devdex.com> wrote in message news:<#rYodEMhEHA.2916@TK2MSFTNGP12.phx.gbl>...
I have a related problem, but one which I can't really use substrings> One solution is to check the length of this particular column that is
> causing wider columns in itemdatabound....
>
> string d = Convert.ToString(DataBinder.Eval(e.Item.DataItem,. ...));
> if (d.Length > 50)
> {
> Label lb = (Label) e.Item.FindControl("lb");
> lb.Text = d.Substring(0, 45) + "...";
>
> }
>
> Hope that helps,
> Ben
on.
I have a column which has generated HTML tags in it. The tag is a link
to a javascript function which needs to be called with the key value
of the row, and also has a JPG embedded in it. I want to be able to
use this as my grid needs to be dynamic - I don't always want to
display this column.
As you can guess, the DataGrid is resizing my grid so that the column
takes up space commensurate with the size of the text which generates
the link, rather than the image it displays.
Is there any way I can completely override the column width so it
doesn't "correct" it in this way?
Mike.
Mike Hutton Guest



Reply With Quote

