Data Grid Column Widths

  • Thread starter Thread starter sck10
  • Start date Start date
S

sck10

Hello,

I am using a datagrid and am trying to control the column widths for each
column. Is this possible? I have tried using the following:
ControlStyle-BorderWidth="1000" with no apparent results.
temStyle-BorderWidth="200" with my column turning black.
ControlStyle-Width="200" with no apparent results.

Any help would be appreciated.

--
Thanks in advance,

sck10

Snippet:
--------
<!-- GridView: Show list of web documents -->
<asp:GridView ID="gvWebDocList" Runat="server" DataSourceID="dsWebDocList"
AutoGenerateColumns="False" AllowPaging="True" PageSize="40"
PagerSettings-Mode="Numeric"
CellPadding="3" HeaderStyle-HorizontalAlign="Center"
CssClass="sckArial_BlkM08"
RowStyle-CssClass="sckArial_BlkM08"
HeaderStyle-CssClass="sckArial_BlueB08"
HorizontalAlign="Left"
BorderWidth="1px"
RowStyle-BorderColor="#000000" RowStyle-BorderStyle="Solid"
GridLines="Both">
<Columns>
<asp:BoundField HeaderText="Doc Group" DataField="strWebDocGroup" />

<asp:BoundField HeaderText="Doc Type" DataField="strWebDocType" />

<asp:HyperLinkField
HeaderText="Title"
DataTextField="strWebAddress"
DataNavigateUrlFields="strWebAddress"
SortExpression="strWebAddress" />

<asp:TemplateField
headertext="Submitter">
<itemtemplate>
<a
href='mailto:<%#Eval("strOwnerEmail")%>'><%#Eval("strSubmitter")%></a>
</itemtemplate>
</asp:TemplateField>

</Columns>
</asp:GridView>
 
You can try something like this...

<asp:datagrid id="dgTimes" CssClass="DataGrid" runat="server"
AutoGenerateColumns="False" CellPadding="0"
GridLines="None">
<Columns>
<asp:BoundColumn Visible="False" DataField="OpenHouseID"
ReadOnly="True"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Mls Numer">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Height="25px" Width="70px"
VerticalAlign="Middle"></ItemStyle>
<ItemTemplate>
<asp:Label ID="Label1" Runat="server" CssClass="labelBlue">
<%# DataBinder.Eval(Container.DataItem,"MlsNumber") %>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label2" Runat="server" CssClass="labelBlue">
<%# DataBinder.Eval(Container.DataItem,"MlsNumber") %>
</asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
 
Hi Sck10,

I think Alex's suggestion is reasonable , generally in the asp.net 1.1's
DataGrid, we can use the
"HeaderStyle-Width" or "ItemStyle-Width" to adjust the columns's width(
both should ok). For example:

<asp:BoundColumn HeaderStyle-Width="100"></asp:BoundColumn>
<asp:BoundColumn ItemStyle-Width="100"></asp:BoundColumn>

I think the GridView may have the same behavior. You may have a try to see
whether they work. If there're any other problems, please feel free to post
here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Sck10,

Have you had a chance to check the suggestions in my last reply or have you
got any further ideas on this issue? If there're anything else we can help,
please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top