我做了一个用户自定义控件来显示数据库中的记录,但如果一段文字超过我规定的宽度,它会把我的表格撑大,这是为什么?
下面是具体的代码:
<%@ Control Language="C#" ClassName="showlr" %>
<%@ Import Namespace ="System.Data.OleDb" %>
<%@ Import Namespace ="System.Data" %>
<script runat="server">
private String HtmlCode(string TString)
{
if (TString != null)
{
TString = TString.Replace("\r", "<br>");
TString = TString.Replace(" ", " ");
TString = TString.Replace("[", "<img src=").Replace("]", ">");
return TString;
}
else
{
return TString = "无内容";
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
</script>
<table border="0" cellpadding="0" cellspacing="0" width="640" align="center" >
<tr>
<%
string cs=Request["idh"].ToString();
string fdir = Server.MapPath("") + "\\App_Data\\wj.mdb";
string sqlstr = "select * from lr where id=" + cs;
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + fdir);
DataSet ds = new DataSet();
OleDbDataAdapter dr= new OleDbDataAdapter(sqlstr ,con);
dr.Fill(ds, "lr");
%>
<td bgcolor="#89b1dc" style="border-right: #cccccc thin solid; border-top: #cccccc thin solid;
border-left: #cccccc thin solid; border-bottom: #cccccc thin solid; text-align: center"
width="100%">
<%= ds.Tables[0].Rows[0][2].ToString() %></td>
</tr>
<tr>
<td width="100%" style="text-align: center">
作者:
<%= ds.Tables[0].Rows[0][3].ToString()%>
上传时间:<%= ds.Tables[0].Rows[0][5].ToString().Substring(0, ds.Tables[0].Rows[0][5].ToString().Length - 7)%>
</td>
</tr>
<tr>
<td width="640" align="left" >
<hr color="#89b1dc" />
<%=HtmlCode(ds.Tables[0].Rows[0][4].ToString())%>
</td>
</tr>
</table>
红色标的是有多段文字的显示语句