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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid column widths

Status
Not open for further replies.

RamHardikar

Programmer
Feb 16, 2001
109
GB
Am using a DataGrid to display data. Also, am using custom paging since i have lot of data to be shown. when i navigate thru pages the data shows up on the gird. till here i dont hv a problem.

when i navigate thru pages, the DataGrid columns that are showing the data dont seems to be fixed. in the sense the column width always changes on very page. is there a way to keep the column widths fixed all thruout the pages during navigation?
 
In the ItemCreated event you can set the width of the cell. e.g.
Code:
e.Item.Cells(0).Width = New Unit(100, System.Web.UI.WebControls.UnitType.Pixel)

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Code:
<asp:DataGrid id="DataGrid1" runat="server">
 <Columns>
  <asp:BoundColumn HeaderStyle-Width="150" ></asp:BoundColumn>
  <asp:TemplateColumn HeaderStyle-width="150">
   <div style="width:100%;overflow:hidden" ><%# DataBinder.Eval(Container.DataItem, "WideContent")%></div>
  </asp:TemplateColumn>
 </Columns>
</asp:DataGrid>


The overflow cliping is optional. It clips very large data and keeps it from make the grid to ugly. This is good when the user only needs to see a small portion of a large amount of text.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top