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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jonathan

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

    I am new to Datagrids and asp.net (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?

    </head>

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

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

    Sub Page_Load(Sende r as Object, E as EventArgs)

    Dim oConn As OleDbConnection
    Dim oComm As OleDbDataAdapte r
    Dim sConn As String
    Dim sComm As String
    Dim oDataSet As New DataSet

    'Build the connection string
    sConn = "Provider=Micro soft.Jet.OLEDB. 4.0;"
    sConn += "Data Source=D:\inetp ub\www\mysite\m yaccessdb.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 OleDbDataAdapte r(sComm, oConn)

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

    'Set the grid source to the dataset and bind the data
    oGrid.DataSourc e=oDataSet.Tabl es("qryDataGrid 01").DefaultVie w
    oGrid.DataBind( )

    End Sub
    </script>


    <asp:DataGrid runat="server" id="oGrid" BackColor="#eee eee"
    HorizontalAlign ="Left">
    <HeaderStyle Font-Bold="True"/>
    <AlternatingIte mStyle BackColor="Whit e" />
    </asp:datagrid>


  • David Wier

    #2
    Re: How do I set Datagrid column widths (ASP Vb.Net)?

    Check out this tip from ASPNet101.com:


    David Wier

    http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
    bloated markup


    "Jonathan" <none@none.comw rote in message news:fpbm4d$sjr $1@aioe.org...
    >I am new to Datagrids and asp.net (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?
    >
    </head>
    >
    <%@ Page language="VB" Debug="true" %>
    <%@ Import Namespace="Syst em.Data" %>
    <%@ Import Namespace="Syst em.Data.OleDb" %>
    >
    <script language="VB" runat="server">
    >
    Sub Page_Load(Sende r as Object, E as EventArgs)
    >
    Dim oConn As OleDbConnection
    Dim oComm As OleDbDataAdapte r
    Dim sConn As String
    Dim sComm As String
    Dim oDataSet As New DataSet
    >
    'Build the connection string
    sConn = "Provider=Micro soft.Jet.OLEDB. 4.0;"
    sConn += "Data Source=D:\inetp ub\www\mysite\m yaccessdb.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 OleDbDataAdapte r(sComm, oConn)
    >
    'Fill the dataset with the results of the query
    oComm.Fill(oDat aSet, "qryDataGrid01" )
    >
    'Set the grid source to the dataset and bind the data
    oGrid.DataSourc e=oDataSet.Tabl es("qryDataGrid 01").DefaultVie w
    oGrid.DataBind( )
    >
    End Sub
    </script>
    >
    >
    <asp:DataGrid runat="server" id="oGrid" BackColor="#eee eee"
    HorizontalAlign ="Left">
    <HeaderStyle Font-Bold="True"/>
    <AlternatingIte mStyle BackColor="Whit e" />
    </asp:datagrid>
    >
    >

    Comment

    Working...