ItemStyle from DataGrid

Discussion in 'ASP .Net' started by Paul King, Jul 21, 2004.

  1. Paul King

    Paul King Guest

    Hi there,

    Im trying to setup an ASP DataGrid to format my results in a clear manner.

    I have 3 fields to bring back into the grid, these are Date, Venue and
    Comments.

    However I would like to restrict the width of the comments records to a
    certain value - can this be done?

    Regards
    Paul
    Paul King, Jul 21, 2004
    #1
    1. Advertising

  2. "Paul King" <> wrote in message
    news:%...
    > Hi there,
    >
    > Im trying to setup an ASP DataGrid to format my results in a clear manner.
    >
    > I have 3 fields to bring back into the grid, these are Date, Venue and
    > Comments.
    >
    > However I would like to restrict the width of the comments records to a
    > certain value - can this be done?


    If you mean the width on the screen, yes, you can set the column widths.

    If you want to limit the number of characters which a user can enter into
    the Comments field, you'll have to do that yourself before writing to the
    database.
    --
    John Saunders
    johnwsaundersiii at hotmail
    John Saunders, Jul 21, 2004
    #2
    1. Advertising

  3. Paul King

    Paul King Guest

    Yes ok, but how do you set the Width on the screen?

    For example I want the whole ASP Form only to be a certain size.

    Regards
    Paul.

    "John Saunders" <> wrote in message
    news:...
    > "Paul King" <> wrote in message
    > news:%...
    > > Hi there,
    > >
    > > Im trying to setup an ASP DataGrid to format my results in a clear

    manner.
    > >
    > > I have 3 fields to bring back into the grid, these are Date, Venue and
    > > Comments.
    > >
    > > However I would like to restrict the width of the comments records to a
    > > certain value - can this be done?

    >
    > If you mean the width on the screen, yes, you can set the column widths.
    >
    > If you want to limit the number of characters which a user can enter into
    > the Comments field, you'll have to do that yourself before writing to the
    > database.
    > --
    > John Saunders
    > johnwsaundersiii at hotmail
    >
    >
    Paul King, Jul 21, 2004
    #3
  4. "Paul King" <> wrote in message
    news:...
    > Yes ok, but how do you set the Width on the screen?
    >
    > For example I want the whole ASP Form only to be a certain size.


    Paul,

    This sort of thing is typically done through styles - either inline styles
    or by using CSS classes. For instance, if you wanted to design for an
    800x600 screen, you could start off your design by adding a Panel control to
    the form and setting the Panel's Height and Width properties. You can then
    drag controls into the Panel, and, for instance, set their width to 100%:

    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    Inherits="WebApplication1.WebForm1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:panel Runat="server" Height="600px" Width="800px"
    id="Panel1">
    <asp:DataGrid id="DataGrid1" runat="server"
    Width="100%"></asp:DataGrid>
    </asp:panel>
    </form>
    </body>
    </HTML>

    You can lay out the space within the Panel by using tables, and again you
    can set the width and/or height to 100%. This way you only have to change
    width and/or height in one place.
    --
    John Saunders
    johnwsaundersiii at hotmail
    John Saunders, Jul 21, 2004
    #4
  5. Paul King

    Paul King Guest

    Thanks - thats works a gem

    Cheers
    Paul.
    "John Saunders" <> wrote in message
    news:...
    > "Paul King" <> wrote in message
    > news:...
    > > Yes ok, but how do you set the Width on the screen?
    > >
    > > For example I want the whole ASP Form only to be a certain size.

    >
    > Paul,
    >
    > This sort of thing is typically done through styles - either inline styles
    > or by using CSS classes. For instance, if you wanted to design for an
    > 800x600 screen, you could start off your design by adding a Panel control

    to
    > the form and setting the Panel's Height and Width properties. You can then
    > drag controls into the Panel, and, for instance, set their width to 100%:
    >
    > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"

    AutoEventWireup="false"
    > Inherits="WebApplication1.WebForm1" %>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > <HTML>
    > <body>
    > <form id="Form1" method="post" runat="server">
    > <asp:panel Runat="server" Height="600px" Width="800px"
    > id="Panel1">
    > <asp:DataGrid id="DataGrid1" runat="server"
    > Width="100%"></asp:DataGrid>
    > </asp:panel>
    > </form>
    > </body>
    > </HTML>
    >
    > You can lay out the space within the Panel by using tables, and again you
    > can set the width and/or height to 100%. This way you only have to change
    > width and/or height in one place.
    > --
    > John Saunders
    > johnwsaundersiii at hotmail
    >
    >
    Paul King, Jul 21, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Clive

    ItemStyle ForeColor on a datagrid

    Clive, Jul 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,022
    Clive
    Jul 14, 2003
  2. matthew schouppe
    Replies:
    3
    Views:
    2,345
    Scott Allen
    Apr 30, 2004
  3. Diego
    Replies:
    0
    Views:
    555
    Diego
    Nov 12, 2004
  4. Replies:
    1
    Views:
    1,629
    Scott Allen
    Apr 29, 2005
  5. matthew schouppe

    DataGrid ItemStyle is a textbox and doesn't update the datagrid datasource

    matthew schouppe, Apr 29, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    193
    Scott Allen
    Apr 30, 2004
Loading...

Share This Page