May 24, 2011

Fixed the size of gridview

How can i fixed the size of grid with respect to their hieght and width. Problem occurs on address column when long address placed in it it increase its width and sperad its width from page. Thats why i wants that if address is will increase the width of gridview rather moving forward its terminated line and then placed reamining words in next lines. I fixed the width of gridview and reamins free in auto mode the height of gridview.

There are several ways u can solve that issue by just taking an item template and put your address bounded column in that item template


<asp:TemplateField HeaderText="Title" SortExpression="Title" ItemStyle-Width=200>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<HeaderStyle VerticalAlign="Middle" />

<asp:Label ID="Label1" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
<ControlStyle Width="200px" /> </asp:TemplateField>