Tracking Forums, Newsgroups, Maling Lists
Home Submit Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










Forms Data Controls :: Make GridView Column Fixed In Width?


How to set the GridView column fixed in width size whether there is data in the column cell or not. I try below code using "ItemStyle-Width" in the BoundField control to fix the column width but column became narrower if there is no data to display in it. Is this a no solution of ASP Gridview control ?

<asp:GridView
ID="GridView1"
runat="server"
AutoGenerateColumns="false"
Font-Names="Arial"
Font-Bold="true"......


View 2 Replies (Posted: Jan 31, 2011 07:07 AM)

Sponsored Links:

Related Forum Messages For ASP.NET category:
Forms Data Controls :: GridView Column Set Fixed Width
I am trying to set the width of each column within my gridview. Problem is that none of it is working. I have tried setting the whole grid view to 100% and then break down each individual column to a certain percentage, tried manually adjusting Header Width, Item Style width, tried setting it in code, I have tried just about everything and the column doesn't want to budge. The only time I can adjust the width of the column/cell is when I do it in SQL, but because they are requesting the tooltip to preview the comment I would like to pursue my options doing it on the page itself.

//Code protected void grdComments_RowDataBound(object sender, GridViewRowEventArgs e)
{//Setting the tooltip for the comment column and column width.
grdComments.Columns[3].ItemStyle.Width = Unit.Pixel(100);
//e.Row.Cells[3].Width = Unit.Pixel(100);
e.Row.Cells[3].Wrap = false;
e.Row.Cells[3].Style["overflow"] = "hidden";
e.Row.Cells[3].Style["text-overflow"] = "ellipsis";
e.Row.Cells[3].ToolTip = e.Row.Cells[3].Text; }

Posted: Dec 27, 2010 04:27 PM

View 3 Replies!   View Related
Make A Column Width Size Fixed In Datagridview Asp?
i have this column in a datagridview on aspx page

<asp:TemplateField HeaderText="Observacion">
<ItemTemplate>
<asp:Label ID="lblOrderID" runat="server" Text='<%# Eval("Observacion") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="200px" Wrap="False" />
</asp:TemplateField>

I have set up the itemstyle with and wrap to false, but anyways the width columns grows the the data is too long. i just want to change the height of the column not the width. Here us the complete code of the datagridview

<asp:GridView ID="GridView1" runat="server" AutoGenerateDeleteButton="True" CellPadding="4" EnableModelValidation="True" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False">
<columns>
<asp:boundfield datafield="ID_OBSERVACION" visible="False" />
<asp:boundfield datafield="AUTOR" headertext="Autor" />
<asp:boundfield datafield="FECHA" headertext="Fecha" />
<asp:TemplateField HeaderText="Observacion">
<ItemTemplate>
<asp:Label ID="lblOrderID" runat="server" Text='<%# Eval("Observacion") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="200px" Wrap="False" />
</asp:TemplateField>
</columns>
<AlternatingRowStyle BackColor="White" ForeColor="#284775" Wrap="False" />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" Wrap="False" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>

Posted: Dec 29 10 at 22:32

View 1 Replies!   View Related
Forms Data Controls :: Datagrid Fixed Column Width
I m working on Datagrids and i am trying to specify a fixed width for a Column(in datagrid) ...Is there any property to specify the width of the columns in datagrid(i knowits pretty easy tospecify the width of the Datagrid but i want to specify the fixed column width) Also how do i specify the text wrapping ina datagrid

Posted: Oct 12, 2010 02:35 AM

View 1 Replies!   View Related
C# - Fixed Header Column Width In Gridview?
I want to set header column width for grid view. I tried HeaderStyle-Width="30px". But it is depending on Item columns. The column width is setting based on item value. But I want fixed width even if it has value or empty.

Posted: Nov 16 10 at 4:34

View 1 Replies!   View Related
Forms Data Controls :: Set The Columns Width To Fixed Value In Gridview?
how to set the fixed value with the columns in a grid view? my code works fine if you have normal words with space. If the length of the whole field is more than its width, It would come to the next line. But If we type big word without any space like "WWWWWWWWWWWWWWWWWWWWWWWWWWWWW", It would by default increase the width and disturbs the layout.

Posted: Oct 25, 2010 09:19 PM

View 4 Replies!   View Related
Forms Data Controls :: How To Make Fixed Header In GridView
I am able to put gridview inside asp:panel and scrolling works too. But the moment I down, the header of gridView scrolls above inside the panel and gets hidden.

I just want to scroll rows, not the header. How can I do that?. Following is what I am using.

On a side note, I have tried to wrap gridView in DIV but div doesn't show the scroll bars in the first load for some reason.

[code]....

Posted: Jun 04, 2010 06:35 PM

View 2 Replies!   View Related
Forms Data Controls :: Set Gridview Column Width
How canI set GridView column width? I would like to show"Edit", "Delete" and "Details" links in the same row. Currently these links are wrapped in three different lines.

Posted: Jan 26, 2010 10:39 PM

View 5 Replies!   View Related
Forms Data Controls :: Set The Width Of Column On GridView?
How to set the specific the width ofeach column,the columns arecreatedautomaticly

Posted: Sep 02, 2010 06:56 AM

View 3 Replies!   View Related
Forms Data Controls :: Specify Gridview Column Width?
I have created a database containing information of 3,000 military veterans using asp.net DataView. The display is complete showing all records and I am able to sort on any column. I need to specify the GridView width and the width of individual columns. I have searched the Internet and found no solution to my problem. Here is my code.

<form runat="server">
<asp:AccessDataSource runat="server">
</asp:AccessDataSource>
<asp:GridView runat="server" AutoGenerateColumns="False"
DataSourceID="AccessDataSource2" BorderStyle="Solid" BackColor="White" BorderColor="Blue" BorderWidth="3px" CellPadding="3"
Caption="1st Signal Brigade Association Database"
Font-Size="Smaller" AllowSorting="True" HorizontalAlign="Center">
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" Wrap="False" />
<Columns>
<asp:boundfield DataField="LastName" HeaderText="Last Name" SortExpression="LastName">
</asp:boundfield>
<asp:boundfield DataField="FirstName" HeaderText="First Name" SortExpression="FirstName">
</asp:boundfield>
<asp:boundfield DataField="Street" HeaderText="Street" SortExpression="Street">
</asp:boundfield>
<asp:boundfield DataField="City" HeaderText="City" SortExpression="City">
</asp:boundfield>
<asp:boundfield DataField="State" HeaderText="State" SortExpression="State">
</asp:boundfield>
<asp:boundfield DataField="Zip" HeaderText="Zip" SortExpression="Zip">
</asp:boundfield>
<asp:boundfield DataField="Phone" HeaderText="Phone" SortExpression="Phone">
</asp:boundfield>
<asp:boundfield DataField="Email" HeaderText="Email" SortExpression="Email">
</asp:boundfield>
<asp:boundfield DataField="Years" HeaderText="Years" SortExpression="Years">
</asp:boundfield>
<asp:boundfield DataField="UnitName" HeaderText="Unit Name" SortExpression="UnitName">
</asp:boundfield>
</Columns>
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<PagerStyle HorizontalAlign="Right" BackColor="#E7E7FF" Font-Bold="True" Font-Names="Arial" Font-Size="Smaller" ForeColor="#4A3C8C" Wrap="False" Width="15px" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" Wrap="False" />
<HeaderStyle HorizontalAlign="Left" Wrap="False" BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" Font-Size="Small" Width="15px" />
<AlternatingRowStyle BackColor="#F7F7F7" />
</asp:GridView>
<asp:AccessDataSource runat="server" DataFile="Brigade DB1.mdb" SelectCommand="SELECT [LastName], [FirstName], [Street], [City], [State], [Zip], [Phone], [Email], [Years], [UnitName] FROM [Membership]">
</asp:AccessDataSource>
</form>

Can anyone provide me with the additional code to size the Gridview and the columns?

Posted: Nov 12, 2009 01:38 AM

View 1 Replies!   View Related
Forms Data Controls :: Set Column Width In Gridview
I'mtrying to set the width of gridview'scolumn.

1) I have a template field with the HeaderText="WheelChair" that has a checkbox. Just for checkbox its taking the width thatof the HeaderText. How do I setthe width of this column just enough to fit the checkbox or how do I break the HeaderText of such columns.

2) Also I haveanother column 'Address' . I don't want to wrap thecontent in such columns.

Posted: Jun 29, 2010 06:48 PM

View 2 Replies!   View Related
Forms Data Controls :: Fix Column Width Of Gridview
<asp:GridView ID="GridView1" runat="server" CellPadding="10" ForeColor="Black"
GridLines="None" AutoGenerateColumns="False"
BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="10px"
CellSpacing="10" AllowPaging="True" PageSize="1" Height="169px"
onpageindexchanging="GridView1_PageIndexChanging" Width="100px">
<Columns>
<asp:HyperLinkField NavigateUrl="[URL]" HeaderText="view"
Text="view" />
<asp:BoundField DataField="Title" HeaderText="Title" />
<asp:BoundField DataField="Publisher" HeaderText="Publisher" />
<asp:BoundField DataField="Technology" HeaderText="Technology" />
<asp:BoundField DataField="Type" HeaderText="Type" />
<asp:BoundField DataField="Author Name" HeaderText="Author Name" />
<asp:BoundField DataField="Type Of Media" HeaderText="Type Of Media" />
<asp:BoundField DataField="Media_ID" HeaderText="Media_ID" />
<asp:BoundField DataField="Availability" HeaderText="Availability" >
<HeaderStyle Font-Bold="True" Font-Underline="True" />
<ItemStyle Font-Bold="True" Font-Size="Medium" Font-Underline="False" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="Tan" />
<PagerStyle ForeColor="DarkSlateBlue" HorizontalAlign="Center"
BackColor="PaleGoldenrod" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
</asp:GridView>

this is my grid view. my problem is the gridview width is changing with diffent data. when the columns have huge data it is expanding and when columns are filled with small data it is shrinking. i have applied wrapping thing to columns too i want to have a grid view which will be consistently displayed in unique size what ever the data is filled.

Posted: Feb 11, 2009 09:42 AM

View 6 Replies!   View Related
Forms Data Controls :: How To Set Column/ Cell Width In Gridview
i need to set the column width of my gridview.

However the the column in the gridview is dynamic created which might more or less depend on system logic.

I have try to set the column width in row_created event, rowDataBound event, but it show me that no column is available by using gridview.columns.count.

Posted: May 11, 2010 06:29 PM

View 5 Replies!   View Related
Forms Data Controls :: Programmatically Set Gridview Column Width
After binding a gridview to a datareader - Im trying to set the width of the firstcolumn by using :

[Code]....

this is giving me an error : Index was out of range. Must be non-negative and less than the size of the collection.

Posted: Jan 08, 2010 10:20 AM

View 3 Replies!   View Related
Forms Data Controls :: Unable To Set GridView Column Width
I have been searchingthe internet for a solution to this for hours. I have tried all of the following methods to set the column width on my GridView control:

1. <asp:TemplateField HeaderText="ColumnHeader" ItemStyle-Width="100px">
2. <ItemStyle Width="100px" Wrap="False" />
3. GridView.Columns[0].ItemStyle.Width = 100 both on the PageLoad event and, out of desperation, on the RowDataBound event.

I have tried these settings by themselves and in combination. I have also experimented with different CSS width settings for the GridView and its containing<div> (including none) to no avail. The GridView columns are always equally spaced and wrap the row description text in the first column in a rather ugly fashion. As this needs to be fixed for a presentation to a client on Monday, I would be eternally grateful to anyone who could point me in the right direction.

Posted: Sep 23, 2010 04:52 PM

View 4 Replies!   View Related
Forms Data Controls :: How To Set The Column Width Of GridView At Runtime
All i am trying to do is to set the Column1 to a fixed value and adjust the remaining columns by doing simple Math which is NOT WORKING FOR ME....

I am generating columns at runtime..

[Code]....

Posted: Jun 20, 2007 02:40 AM

View 5 Replies!   View Related
Forms Data Controls :: Unable To Set Column Max Width In A Gridview
I have a gridview and I want to fix the column size to a certain size regardless of the length of the data ina given cell.

I have tried everythign I can think of from

gvwProjects.Columns[1].ItemStyle.Width
gvwProjects.Columns[1].ItemStyle.Wrap

to setting the length of the lblContol in the template but no matter what I do the column size automatically increases beyond my fixed size to meet the size of the longest cell in the bound datatable.

Posted: Feb 19, 2010 05:27 PM

View 1 Replies!   View Related
Forms Data Controls :: How To Control Gridview's Column Width
How do I control the gridview's column width wherein my gridview is dynamically populated from a dataset. What I want to achieve is to have a somewhat uniform column width for all column entries. I have already tried specifying the Itemstyle-width = "desired column" width but still the content of the dataset still dictates the final width of the column. When I also try to set the ItemStyle-Warp = false, it does not still give me the desired effect because it will just increase the column width to fit the content of the dataset. I think to achieve my desired effect and since some contents of the dataset are long, the solution would be to truncate the dataset prior to binding it to the gridview but I don't know how.

Posted: Nov 24, 2009 07:48 AM

View 4 Replies!   View Related
Forms Data Controls :: Gridview Column Width Changes On Paging?
Gridview columns are created programmatically and when displaying the gridview first timeit looks great. But click on a number to go to another page in gridview the column sizechanges and looks terrible, but correct data is displayed.How do I fix the formatting problem?

Posted: Feb 11, 2011 02:49 PM

View 4 Replies!   View Related
Forms Data Controls :: Dynamically Adjusting Gridview Column Width?
I populate a gridview dynamically which has differen column numbers depend on requirements. My goal is to adjust column width dynamically. I have tried several methods and events, then RowCreated event of GridView looks best one to do. My code is as below.When
i check resultat theViewSource on the browser, i can see that width of <td> successfully adjusted. BUT nothing changes on the browser, column width always as wide as text?

My Code [Code]....

HTML RESULT SUCCESSFUl [Code]....

Posted: Oct 03, 2010 11:53 AM

View 5 Replies!   View Related
Forms Data Controls :: Increase Column Width Of Address In Gridview
I have this lastname column and address column. The address obviously is longer so it makes the gridview to increase its height which I don't want to happen. What I want is to increase the column width of the address in gridview that will suit the long text inside it. How could I do it in C#? Currently this are my codes:

C#
[Code]....

CSS
[Code]....

Posted: Jul 09, 2010 03:45 AM

View 11 Replies!   View Related
Forms Data Controls :: Set Gridview Auto Generated Column Width
is there anyway to set gridview autogenerated column width

Posted: Jan 10, 2011 06:38 AM

View 2 Replies!   View Related
Forms Data Controls :: How To Set Specific Width Size On Gridview Column
I want to set specific width size of a column inside grid view i tryed following things butit did not work:

I tryed through css through C# and to set properties for gridview like itemstyle/itemcontrol width = 150px

Posted: Mar 15, 2011 08:14 AM

View 7 Replies!   View Related
Forms Data Controls :: Change The Column Width Of A GridView Programmatically?
Here is my GridView

<asp:GridView ID="GridView1"

Posted: Jul 06, 2010 10:51 AM

View 9 Replies!   View Related
Forms Data Controls :: Make A GridView Column Invisible If Every Cell In That Column Is Empty?
No sense in showing a competely blank column. how to make a GridView column invisible if every cell in that column is empty?

Posted: Mar 04, 2011 11:07 AM

View 3 Replies!   View Related
Forms Data Controls :: How To Change Gridview Column Width And Row Height At Run Time
Currently, I am working on web application in which i am using gridview control. I am setting row height as below:

[code]....

</Columns>

But this is also not reflecing any change in GUI. let me know what I am doing wrong?

Posted: Nov 15, 2007 12:44 AM

View 15 Replies!   View Related
Forms Data Controls :: Unable To Set Width Of Gridview Column When Auto-generated?
I need to control the columns widths so that they don't exceed some certain amount.My gridview binds the datasource from database, and auto generate column is set to true. In this case, I cannot find the gridview.columns becase the count is zero, even after the data is bound. So i cannot use the ItemStyle.width property.I also tried

[Code]....

The value does set on every cells, including header cells, but it doesn't have any effect when the gridview renders.

Posted: Dec 17, 2009 03:36 PM

View 6 Replies!   View Related
Forms Data Controls :: Manually Setting The Column Width On GridView Columns?
I have aGridView with bound columns, for which I am manually setting the ItemWidth and HeaderWidth to 500px, and nothing happens.Is there some trick to getting this to work?

This is a columna large amount of text in it, and it keeps sizing to the width of the header text, which is simply "note". I don't want to setWrap to false, becuase then the colummn could be thousands of px wide in cases.

Posted: Mar 30, 2010 08:16 PM

View 11 Replies!   View Related
Forms Data Controls :: Change Width Of Column In Gridview Bound Field
I want to change the width of column in Gridview bound field but it is not changing. Code Is;

<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address">
<ItemStyle Width="500px" />
</asp:BoundField>

Posted: Nov 25, 2010 07:44 AM

View 3 Replies!   View Related
Forms Data Controls :: Make Gridview Row Width "single Line"
I got a grid view, at certain cells, the data length is long, that it will display like 2 or more rows.

Some sort like multiple line in single cells in Excel.

How can I make the cell only a single line cell. I want the columns to be expandable instead of rows.

Posted: Jul 20, 2010 07:25 AM

View 2 Replies!   View Related
Forms Data Controls :: Trying To Make A Gridview Column A Thumbnail
I can get thefile(image) to display, but it displays at a size that is too large for my use. Basically, right now, I'm pointing the ImageField to the first field in the grid that contains the url of the image. I couldrequire the user to create a smaller image of the file but that seemsa little excessive. Is there any way to control the size of the column displaying the image? Here is the html, we are using LINQ to get the data that is displayed in the grid.

[Code]....

Posted: Jan 22, 2010 11:49 AM

View 4 Replies!   View Related
Forms Data Controls :: Make GridView Column Invisible?
I m getting 9 columns from database in a dataset but I want to diplay only 4 columns in datagrid. Remaining 5 columns values, I want to display in the textboxes below datagird.

I tried it making column invisible. If I make it invisible, I m not getting any value for that column to display in the textbox.

Posted: Sep 29, 2010 08:04 PM

View 2 Replies!   View Related
Forms Data Controls :: Make An Autonumber Column In Gridview?
i have gridview that shows some information i want to have column that be autonumber shows the row number of gridview.for example i have 7 row in gridview it show 1 for first row ,2 second row,3 third row,... how can i do that?

Posted: Mar 25, 2011 08:15 AM

View 3 Replies!   View Related
Forms Data Controls :: Make Text Fit Into Column Of A Gridview?
i'm bindng data to gridview using bound field.one column of gridview is linkbutton.if the text is more than the cell width then the gridview width is increasing automatically.for ex if i have text like "microsoft asp.net forums" then it's displaying the whole text.but i need that text like "microsoft.....".how to display like this in gridview?

Posted: Oct 04, 2010 10:02 AM

View 5 Replies!   View Related
Forms Data Controls :: Set Width Of Pager Different From Width Of GridView?
I'musing a PagerTemplatew/ my GridView. The GridViewsits inside a DIV tag that is about 70% of the screen. Thewidth of theGridView is wider than the DIV tag sothe DIV scrolls at the bottom from left to right.The pager is also fixed at the bottom of the screen. The problem is that the width of the pager isthe same width as the GridView, so it extends all the way to the right and displays over the top of the vertical scrollbar.I want the width of the pager to equal the width of the DIV tag no matter how wide the grid is.I tried setting the width within the CssClass & the width properties of the <PagerStyle> to no avail and it doesn't seem to matter if I apply the style to fix the position of the pager or not.

[Code]....

Posted: Oct 21, 2009 08:11 PM

View 3 Replies!   View Related
Forms Data Controls :: To Set The Width Of A GridView To A Pre-determined Width?
Is there any way to set the width of a GridView to a pre-determined width?

I have set the width of the gridview and all the columns to a % and then to a number of pixels but it does work. The gridview always sets itself to a width required to display all fields and it goes beyond the resolution of the screen. I would like to contain it to 1024 pixels.

Here's my .aspx

[Code]....

Posted: Oct 05, 2010 12:54 AM

View 8 Replies!   View Related
Forms Data Controls :: How To Make Fixed Header When Data Is Empty
how to make fixedheader when data is empty

Posted: Jan 16, 2011 03:35 PM

View 3 Replies!   View Related
Forms Data Controls :: Make A Hierarchical Gridview With 1 Freeze Column?
I want to make a hierarchical gridview with 1 freeze column.

i havefreezea column in general gridview but it was not working on internet explorer 8.

Posted: Dec 04, 2010 04:08 AM

View 3 Replies!   View Related
Forms Data Controls :: Gridview Width / When Add Columns To Gridview The Width Shoots Out Of The Page And The Page Design Is Seems Ruined?
.I am new to asp.net.Is there any way we can limi the width of the gridview in the design mode.

I have to put 15-20 columns on the gridview.When I add columns to gridview the width shoots out of the page and the page design is seems ruined.

i placed it inside the panel and added scrol bars to it. it looks ok when debuggin i.e looks ok in internet explorer but in design mode it ruins the page design.

Posted: Feb 11, 2010 11:37 AM

View 4 Replies!   View Related
Forms Data Controls :: How To Make Width Of A <td> And Position Of It
[Code]....

How can i make width of a <td> and position of it? This datalist make table but i do not know how to make style for <td> inside it.

Posted: Dec 25, 2009 04:26 PM

View 3 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved