不用GridView显示的数据————以及显示厂日期格式时间
2013-02-18 16:24
393 查看
一、前台
<div>
<table id="tb1" border="1px" style="width: 300px;">
<tr>
<td>
编号
</td>
<td>
姓名
</td>
<td>
性别
</td>
<td>
年龄
</td>
</tr>
<%= BinGrid() %>
</table>
</div>
<div>
<asp:Label ID="lblTime" runat="server" Text="2013-02-18"></asp:Label>
</div>
</form>
</body>
</html>
二、后台
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Text;
using BLL;
using Model;
public partial class sample_Default : System.Web.UI.Page
{
private Student stu = new Student();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//显示常日期格式时间
DateTime dt = Convert.ToDateTime(lblTime.Text);
lblTime.Text = dt.ToLongDateString();
}
}
/// <summary>
/// 显示数据
/// </summary>
protected string BinGrid()
{
string Sid, Sname, Gender, Age, Uid = null;
List<StudentInfo> Tree = stu.Student_Select();
string js = "<script type='text/javascript'>";
StringBuilder build = new StringBuilder(js);
foreach (StudentInfo dt in Tree)
{
if (dt != null)
{
Sid = dt.Sid.ToString();
Sname = dt.Sname.ToString();
Gender = dt.Gender.ToString();
Age = dt.Age.ToString();
Uid = dt.Uid.ToString();
if (Sid != null)
{
string jss = "var row = tb1.insertRow();";
jss += "var sid = row.insertCell();";
jss += "sid.innerText='" + Sid + "';";
jss += "var sname = row.insertCell();";
jss += "sname.innerText='" + Sname + "';";
jss += "var gender = row.insertCell();";
jss += "gender.innerText='" + Gender + "';";
jss += "var age = row.insertCell();";
jss += "age.innerText='" + Age + "';";
build.Append(jss);
}
}
}
string last = null;
last = build.ToString() + "</script>";
return last;
}
}
<div>
<table id="tb1" border="1px" style="width: 300px;">
<tr>
<td>
编号
</td>
<td>
姓名
</td>
<td>
性别
</td>
<td>
年龄
</td>
</tr>
<%= BinGrid() %>
</table>
</div>
<div>
<asp:Label ID="lblTime" runat="server" Text="2013-02-18"></asp:Label>
</div>
</form>
</body>
</html>
二、后台
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Text;
using BLL;
using Model;
public partial class sample_Default : System.Web.UI.Page
{
private Student stu = new Student();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//显示常日期格式时间
DateTime dt = Convert.ToDateTime(lblTime.Text);
lblTime.Text = dt.ToLongDateString();
}
}
/// <summary>
/// 显示数据
/// </summary>
protected string BinGrid()
{
string Sid, Sname, Gender, Age, Uid = null;
List<StudentInfo> Tree = stu.Student_Select();
string js = "<script type='text/javascript'>";
StringBuilder build = new StringBuilder(js);
foreach (StudentInfo dt in Tree)
{
if (dt != null)
{
Sid = dt.Sid.ToString();
Sname = dt.Sname.ToString();
Gender = dt.Gender.ToString();
Age = dt.Age.ToString();
Uid = dt.Uid.ToString();
if (Sid != null)
{
string jss = "var row = tb1.insertRow();";
jss += "var sid = row.insertCell();";
jss += "sid.innerText='" + Sid + "';";
jss += "var sname = row.insertCell();";
jss += "sname.innerText='" + Sname + "';";
jss += "var gender = row.insertCell();";
jss += "gender.innerText='" + Gender + "';";
jss += "var age = row.insertCell();";
jss += "age.innerText='" + Age + "';";
build.Append(jss);
}
}
}
string last = null;
last = build.ToString() + "</script>";
return last;
}
}
相关文章推荐
- SQL Server CONVERT() 函数用不同的格式显示日期/时间数据
- 浅析GridView中显示时间日期格式的问题
- GridView中显示时间日期格式问题
- GridView、Repeater等数据控件列数字、货币和日期的显示格式
- GridView、Repeater等数据控件列数字、货币和日期的显示格式
- GridView、Repeater等数据控件列数字、货币和日期的显示格式
- GridView中显示时间日期格式问题
- GridView、Repeater等数据控件列数字、货币和日期的显示格式
- GridView中显示时间日期格式问题
- GridView中显示时间日期格式等问题
- 取从textarea中存到MYSQL的数据以原格式显示问题以及解决MySQL日期处理和标签的使用
- GridView中的日期时间显示格式
- GridView中显示时间日期格式问题
- 浅析GridView中显示时间日期格式的问题
- GridView中显示时间日期格式问题
- GridView、Repeater等数据控件列数字、货币和日期的显示格式 .
- GridView 绑定数据显示段日期格式
- gridview中设置绑定的日期时间类型字段的显示格式
- GridView中显示时间日期格式问题
- GridView、Repeater等数据控件列数字、货币和日期的显示格式