ASP.NET data grid

  • Thread starter Thread starter J. Babe
  • Start date Start date
J

J. Babe

I'm building an ASP.NET application that stores/retrieves data using
MS-Access. I have a datagrid that I want to populate with a datatable.
However, I only want to display certain columns. I'm wondering how I
can manually assign specific columns from the datatable, to specific
columns in the data grid.
Thanks.
 
You can do this by adding a DataGridTableStyle item to the datagrid. See
online help for DataGridTableStyle and DataGridColumnStyle.

Hope it helps...
 
I was wondering if you have to add a reference to System.Windows.Forms
to use the DataGridStyle class in a web application?
 
No, System.Windows.Forms is only for desktop applications.

Only System.Web.UI.WebControls are valid controls for web apps.

bill
 
Your best bet is to limit your query - -
Select Fname, Lname, Email from tablename

instead of Select * from TableName

However, no matter what your query - - you can use the AutoGeneratecolumns
property of the DataGrid:
AutoGeneratecolumns =False

Then, for each Field you need to use, use a boundcolumn tag (inside Column
tags) -- something like:
........AutoGenerateColumns="False"> '<--inside your DataGrid Tag

<columns>

<asp:BoundColumn DataField="product" HeaderText="Product"></asp:BoundColumn>

<asp:BoundColumn DataField="ProdID" HeaderText="ProductID"
ItemStyle-HorizontalAlign="Center"
HeaderStyle-HorizontalAlign="Center"></asp:BoundColumn>

<asp:BoundColumn DataField="Quantity" HeaderText="Quantity"
ItemStyle-HorizontalAlign="Center"
HeaderStyle-HorizontalAlign="Center"></asp:BoundColumn>

</columns>



David Wier
http://aspnet101.com
http://aspexpress.com
 
Back
Top