How do I set Datagrid column widths (ASP Vb.Net)?

How do I set Datagrid column widths (ASP Vb.Net)?

Post by Jonatha » Tue, 19 Feb 2008 19:18:17

I am new to Datagrids and (VB).

In the sample code below, how do I set the Datagrid widths of the 4 columns
I have from the query I have in the in the Access database?


<%@ Page language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script language="VB" runat="server">

Sub Page_Load(Sender as Object, E as EventArgs)

Dim oConn As OleDbConnection
Dim oComm As OleDbDataAdapter
Dim sConn As String
Dim sComm As String
Dim oDataSet As New DataSet

'Build the connection string
sConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
sConn += "Data Source=D:\inetpub\www\mysite\myaccessdb.mdb;"
sConn += "Persist Security Info=False"

'Build the SQL string
sComm = "SELECT qryDataGrid01.* "
sComm += "FROM qryDataGrid01;"

'Create the connection and command objects
oConn = New OleDbConnection(sConn)
oComm = New OleDbDataAdapter(sComm, oConn)

'Fill the dataset with the results of the query
oComm.Fill(oDataSet, "qryDataGrid01")

'Set the grid source to the dataset and bind the data

End Sub

<asp:DataGrid runat="server" id="oGrid" BackColor="#eeeeee"
<HeaderStyle Font-Bold="True"/>
<AlternatingItemStyle BackColor="White" />

How do I set Datagrid column widths (ASP Vb.Net)?

Post by David Wie » Wed, 20 Feb 2008 01:47:05

Check out this tip from

David Wier - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup