Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid column width

Status
Not open for further replies.

dorandoran

Programmer
Oct 11, 2004
48
US
I wonder why the column width for all the columns are same, I set up headerstyle-width and itemstyle width. for example, i only need few space for quantity but it's taking up same space all rest of the column. not to mention, scrolling to right n left. (this is just sample, i have setup headerstyle and itemstyle width for all the columns).


<td colspan=100%>
<div id="div<%# Eval("subCatID") %>" style="display:none;position:relative;left:15px;OVERFLOW: auto;WIDTH:100%" >
<asp:GridView ID="GridView2" AllowSorting="true" BackColor="White" Width=70% Font-Size=X-Small
AutoGenerateColumns=false Font-Names="Verdana" runat="server" DataKeyNames="LocationID" ShowFooter=true
OnPageIndexChanging="GridView2_PageIndexChanging" OnRowUpdating = "GridView2_RowUpdating"
OnRowCommand = "GridView2_RowCommand" OnRowEditing = "GridView2_RowEditing" GridLines=None
OnRowUpdated = "GridView2_RowUpdated" OnRowCancelingEdit = "GridView2_CancelingEdit" OnRowDataBound = "GridView2_RowDataBound"
OnRowDeleting = "GridView2_RowDeleting" OnRowDeleted = "GridView2_RowDeleted" OnSorting = "GridView2_Sorting"
BorderStyle=Double BorderColor="#0083C1">
<RowStyle BackColor="Gainsboro" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#0083C1" ForeColor="White"/>
<FooterStyle BackColor="White" />
<Columns>

<asp:TemplateField HeaderText="ID" SortExpression="ID" Visible="false">
<ItemTemplate><%# Eval("LocationID")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtLocationID" Text='<%# Eval("LocationID")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtLocationID" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>


<asp:TemplateField HeaderText="Name" SortExpression="Name" HeaderStyle-Width="80">
<ItemTemplate><%# Eval("Name")%></ItemTemplate>
<ItemStyle Width="80" />
<EditItemTemplate>
<asp:TextBox ID="txtName" Text='<%# Eval("Name")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtName" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Part" SortExpression="Part">
<ItemTemplate><%# Eval("Part")%></ItemTemplate>
<ItemStyle Width="100%" />
<EditItemTemplate>
<asp:TextBox ID="txtPart" Text='<%# Eval("Part")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPart" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Serial" SortExpression="Serial">
<ItemTemplate><%# Eval("Serial")%></ItemTemplate>
<ItemStyle Width="100%" />
<EditItemTemplate>
<asp:TextBox ID="txtSerial" Text='<%# Eval("Serial")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtSerial" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Expiration" SortExpression="Expiration">
<ItemTemplate><%# Eval("Expiration")%></ItemTemplate>
<ItemStyle Width="100%" />
<EditItemTemplate>
<asp:TextBox ID="txtExpiration" Text='<%# Eval("Expiration")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtExpiration" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Quantity" SortExpression="Quantity">
<ItemTemplate><%# Eval("Quantity")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtQuantity" Text='<%# Eval("Quantity")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtQuantity" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Location" SortExpression="Location">
<ItemTemplate><%# Eval("Location")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtLocation" Text='<%# Eval("Location")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtLocation" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Flight" SortExpression="Flight">
<ItemTemplate><%# Eval("Flight")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtFlight" Text='<%# Eval("Flight")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtFlight" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Status" SortExpression="Status">
<ItemTemplate><%# Eval("Status")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtStatus" Text='<%# Eval("Status")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtStatus" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>

<asp:CommandField HeaderText="Edit" ShowEditButton="True" />
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="linkDeleteProd" CommandName="Delete" runat="server">Delete</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="linkAddProd" CommandName="AddProd" runat="server">Add</asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</td>
 
the html output will probably offer more information than the web controls. load the page and view the source and pull the grid. there is also a good chance that forum215 will provide better insight in the styling issue.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Thanks Jason.

You again helped me and saved me lots of time. I took out the footer template which i dont need for this module bingo it work.

so, the thing is you will have to set up the width at all level, header, item and footer.

Again, Thanks a Lot..
 
rather than set the style for every element individually on the webcontrol, just set the ClassName of the gridview. then use CSS to style all the elements within the grid.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top