AspxGridView控件帮助文档(2)

2019-08-20 20:14

using System.Data;

using System.Data.SqlClient; using System.Collections;

namespace AspxGridView {

public class SysLogDAL {

static string _connectionstring = \数据库连接字符\ public static ICollection GetAllLog() {

ArrayList al = new ArrayList(); DataSet currentDs = new DataSet();

using (SqlConnection currentConn = new SqlConnection(_connectionstring)) {

//获取数据 currentConn.Open();

SqlDataAdapter currentSda = new SqlDataAdapter(\ currentSda.Fill(currentDs, \

DataTable dt = currentDs.Tables[\ foreach (DataRow dr in dt.Rows) {

SysLogEntry e = new SysLogEntry();

e.LogID = Int32.Parse(dr[\

e.OCCDatetime = DateTime.Parse(dr[\ e.Event = dr[\ e.Type = dr[\ e.Creator = dr[\

e.CreateDate = DateTime.Parse(dr[\ e.Remark = dr[\ al.Add(e); }

currentConn.Close(); } return al; } } }

其中SysLogEntry.cs代码如下:

using System;

using System.Collections.Generic; using System.Linq; using System.Web;

namespace AspxGridView {

public class SysLogEntry {

public int LogID { get; set; }

public DateTime OCCDatetime { get; set; }

public string Event { get; set; }

public string Type { get; set; }

public string Creator { get; set; }

public DateTime CreateDate { get; set; }

public string Remark { get; set; } } }

4.使用DataSourceID属性绑定LinqDataSource

ContextTypeName=\

其中AspxGridView.SysLogDAL有一个SysLogEntrys的属性,代码如下(其它代码同例3)

public ICollection SysLogEntrys { get {

return this.GetAllLog(); ; } }

5.使用DataSourceID属性绑定XmlDataSource

其中Sys_Log.xml文件内容如下

3.为AspxGridView绑定嵌套数据

在AspxGridView中允许绑定嵌套数据。也就是一条数据允许再绑定该数据的下级数据。

举个很简单的例子,我们用AspxGridView来显示中国所有省份,然后我们可以为每行数据(每个省)再绑定一个下级数据,也就是每个省对应的所有市的信息,以此类推,我们还可以为每个市再绑定所有县的信息,层层级推。具体展示在页面上就是AspxGridView上的每条数据前面都有一个+号,展开+号,就可以看到下级数据了。

那么应该怎么来绑定嵌套数据呢?

首先要通过设置父AspxGridView的ShowDetailRow=true来开启嵌套。

子AspxGridView定义在父AspxGridView的标签中。

例:Asp.Net代码

OnBeforePerformDataSelect=\

SelectCommand=\查询主表数据的SQL语句\

SelectCommand=\查询从表数据的SQL语句\


AspxGridView控件帮助文档(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:秭归教学实习报告

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: