Groups | Blog | Home
all groups > dotnet faqs > april 2005 >

dotnet faqs : DataGrid Row Auto-Size


Bruce Pullum
4/11/2005 7:25:36 AM
Can Someone please help me get the DATAGRID to keep the row size consistent
when there is 1 row or 50 rows. Right now, if the datagrid has several rows
of data, it is ok, and looks like a normal data grid. However, if the data
goes to 1, 2, 3, etc rows of data, the grid will try to AUTO-SIZE the data
row size, making the few rows of data take up the entire grid size.... This
make the end result look really bad....

Please help with you ideas... I have searched everywhere for a solution to
this...

Thanks,
Mark Newby
4/27/2005 12:00:00 AM
[quoted text, click to view]

I've not tested this out, but try reducing the vertical length of the
datagrid in design view. if there's a couple of inches in design view,
it seems to try and fill to this size even if there's only 1-2 rows --as
if it's using the design-view's size as a minimum size. so try reducing
this minimum size.


TC
7/19/2005 10:18:24 AM
You have to assign the width of every datagrid cell in the .aspx file. In
Vis Studio this is within the html view. Using a templated column it's liek
this:

<asp:TemplateColumn HeaderText="Name">
<ItemTemplate>
<asp:Label id="Name" width=60 runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Name") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="NameEdit" width=130 runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Name") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>

TC

[quoted text, click to view]

AddThis Social Bookmark Button