ItemStyle from DataGrid

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
 
J

John Saunders

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.
 
P

Paul King

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.
 
J

John Saunders

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.
 
P

Paul King

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top