ItemStyle from DataGrid

  • Thread starter Thread starter Paul King
  • Start date Start date
P

Paul King

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 said:
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.
 
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.
 
Paul King said:
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.
 
Thanks - thats works a gem

Cheers
Paul.
John Saunders said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top