473,626 Members | 3,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fixed column width for table created from database

1 New Member
hi there, i've recently started a student placement as a web developer and wondered if anyone could help me with the following problem:

I'm using an ashx file to access messages that are stored in a database and outputting the results into a string builder. The problem I'm having with this method is that depending on the varying length of user names, messages etc. That the end result can appear messy when output onto the web browser. I will submit the code for the ashx file that I am using:

Expand|Select|Wrap|Line Numbers
  1. <%@ WebHandler Language="C#" Class="AjaxHandler" %>
  2.  
  3. using System;
  4. using System.Data;
  5. using System.Text;
  6. using System.Web;
  7. using ChatClassLibrary.DataAccess;
  8.  
  9. public class AjaxHandler : IHttpHandler {
  10.  
  11.     public void ProcessRequest (HttpContext context) {
  12.         context.Response.ContentType = "text/plain";
  13.         context.Response.Expires = 0;
  14.         context.Response.Clear();
  15.  
  16.         int userID = Convert.ToInt32(context.Request.Params["uid"]);
  17.         int lastRead = Messages.GetLastReceived(userID);
  18.  
  19.         DataTable results = Messages.GetLatestMessages(userID, lastRead);
  20.  
  21.         if (results.Rows.Count > 0)
  22.         {
  23.             StringBuilder sb = new StringBuilder();
  24.             sb.Append("<table border='0' width= '750px' id='chatTable'  class='overflow' >");
  25.            ;
  26.  
  27.             sb.Append("<tbody>");
  28.             foreach (DataRow row in results.Rows)
  29.             {
  30.                 sb.Append("<tr width='200px'>");
  31.  
  32.                 sb.Append("<td style='width:50px' >");
  33.                 string userName = row["UserName"].ToString();
  34.                 sb.Append(userName);
  35.                 sb.Append("</td>");
  36.  
  37.                 sb.Append("<td style='width:50px'>");
  38.                 string message = row["MsgContent"].ToString();
  39.                 sb.Append(message);
  40.                 sb.Append("</td>");
  41.  
  42.                 sb.Append("<td style='width:50px'>");
  43.                 string time = row["TimeSent"].ToString();
  44.                 sb.Append(time);
  45.                 sb.Append("</td>");
  46.  
  47.                 sb.Append("<td style='width:50px'>");
  48.                 string delete = "Del";
  49.                 sb.Append(delete);
  50.                 sb.Append("</td>");
  51.  
  52.                 sb.Append("</tr>");
  53.  
  54.  
  55.             }
  56.             sb.Append("</tbody>");
  57.             sb.Append("</table>");
  58.             context.Response.Write(sb.ToString());
  59.         }
  60.         else
  61.         {
  62.             context.Response.Write("");
  63.         }
  64.     }
  65.  
  66.     public bool IsReusable {
  67.         get {
  68.             return false;
  69.         }
  70.     }
  71.  
  72. }
  73.  
Can anyone offer me some advice on the best way to approach this problem? I've only just started the placement and am working with ASP.NET, C#, Javascript, Ajax, DotNetNuke, which are all new to me. I hope I've been reasonlably clear with my question, any replies appreciated.

Thanks,

Davo
Sep 4 '07 #1
1 1366
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TSDN!

I am moving this to the .NET forum where you'll probably more likely to find someone who can help you solve your problem.

Please use CODE tags when posting code. Thanks!

Normally, you can specify a language too, but there doesn't seem to be one for C# at the moment.
Sep 4 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
64865
by: Bart Heinsius | last post by:
Hi, I can't get my cell widths fixed in a table in IE6. In Mozilla it works, see http://www.xs4all.nl/~margreeh/aa.html . It's the blue cells that remain fixed at 20pt widths in Mozilla but not in IE. The HTML was generated with Mozilla's Composer. Can anyone help getting this to work in IE? Thanks already, Bart.
179
44347
by: SoloCDM | last post by:
How do I keep my entire web page at a fixed width? ********************************************************************* Signed, SoloCDM
0
2622
by: TJ Talluto | last post by:
<facts> I have a "month calendar" that always displays exactly 42 days... and alongside is a vertical box that displays the detail (form fields) of any particular select event that appears on the calendar, so that the event may be changed, or a new event may be created. monthname X X X X X X X form X X X X X X X form X X X X X X X form
1
2436
by: Lalit Bhatia | last post by:
how can we fix first column in DataGrid? Regards, Lalit Bhatia
0
1449
by: Lalit Bhatia | last post by:
thanks for the answer but I need it for windows forms. I have a desktop application where I need to implement this. -- Regards, Lalit Bhatia "Mona" <mona@discussions.microsoft.com> wrote in message news:OQ0wkCeZFHA.3220@TK2MSFTNGP14.phx.gbl... > Hi Lalit,
25
36347
by: Michael Schuerig | last post by:
I'm trying to do something seemingly very simple, but it's brought me close to crushing my head on the keyboard. All I want is a table where the head row is fixed and the body columns below are scrollable (with the ordinary scrollbars, no less). Whatever I try, the columns in the head and the body aren't aligned; the widths are computed independently which gives a completely ragged look. Michael --
0
1138
by: Jay Levitt | last post by:
I'm putting together a small brochureware site to sell my house (http://www.wellesleycarriagehouse.com). The designer used tables initially, but I'm trying to get it as semantic and CSS-ish as possible, as a programming exercise if nothing else. The two-column float layouts I've seen require me to specify the width of both columns, either as percentages or fixed, but that's not information I have available in the CSS. At this stage,...
2
12929
by: dfdavis.mtu | last post by:
I have a table that I dynamically fill with data from a database for medical companies to be able to determine if their patients meet certain criteria. However they want a fixed header for it so they can keep track of the criteria as they scroll since there can be upwards of 1000 or more patients in the table. The way I got this to work was to enter the information in a table via C# by storing it in a label. This works fine and scrolls...
4
3983
by: Jeff | last post by:
Hey I'm wondering how the Fixed-Width Text Format is What I know is that the top line in this text format will contain column names. and each row beneath the top line represent for example a row in a table etc... But does fixed-with mean that every column has a fixed with: for example first column is 10 char wide and second column is 30 char wide?
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.