SmartSqlDataSource
SmartSqlDataSource与search控件、Repeater控件搭配展示数据
页面代码:
<%@ Page Title="" Language="C#" MasterPageFile="~/Layouts/List.Master" AutoEventWireup="true"
CodeBehind="UserContactsList.aspx.cs" Inherits="QASupervision.Modules.SecurityConsole.User.UserContactsList" %>
<%@ Import Namespace="Bingosoft.Modules.SecurityConsole.Common.Helper" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
var Global = {};
Global.contextPath = '<%= RequestHelper.GetContextPath(Request) %>';
</script>
<script src="../../../Scripts/DialogPopup/DialogPopup.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
<div class="search" style="margin-top: 2px;width:97%">
<web:search ID="GridSearch" GridViewId="rpUserList" runat="server">
<SearchConditionTemplate>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th>
用户名称:
</th>
<td>
<asp:TextBox ID="Name" name="Name" runat="server" Width="120px"></asp:TextBox>
</td>
</table>
</SearchConditionTemplate>
</web:search>
</div>
<div class="datalist">
<h2>
<span class="floatr"></span>用户信息
</h2>
<!-- 工具栏 -->
<div class="toolbar">
<asp:Button ID="btnSearch" runat="server" OnClick="RefreshGrid" Style="display: none" />
</div>
<div class="datagrid " style="clear: left;">
<!--------------------------- List Area --------------------------->
<ul style="min-width:700px;_width:700px;">
<asp:Repeater ID="rpUserList" DataSourceID="SmartDataSource1" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<div class="userList" style="float: left; width: 220px;height:105px; text-align: center;">
<div class="block" style="width: 225px;">
<div class="user" style="width: 76px;">
<img alt='<%# Eval("USER_NAME") %>' width="70px" src='<%# !string.IsNullOrEmpty(Eval("ImageURL").ToString())? Eval("ImageURL").ToString():"../../../App_Themes/blue2/images/user.gif"%>' /><br/>
<a href="#" _keyid='<%#Eval("USER_ID") %>' onclick="openAllEditor(this,'View')">
<div class="title_P"><%#Eval("USER_NAME") %></a></div>
</div>
<div class="text" style="width: 130px;">
<table width="100%">
<tr>
<td style="width: 50px; vertical-align: top;">
部门:
</td>
<td align="left" style="width: 80px;">
<%#Eval("ORG_NAME")%>
</td>
</tr>
<tr>
<td style="width: 50px; vertical-align: top;">
座机:
</td>
<td align="left" style="width: 80px;">
<%#Eval("Telephone")%>
</td>
</tr>
<tr>
<td style="width: 50px; vertical-align: top;">
手机:
</td>
<td align="left" style="width: 80px;">
<%#Eval("MOBILE")%>
</td>
</tr>
<tr>
<td style="width: 50px; vertical-align: top;">
邮箱:
</td>
<td align="left" style="width: 80px; word-break: break-all; word-wrap: break-word;">
<%#Eval("EMAIL")%>
</td>
</tr>
</table>
</div>
</div>
<br />
<div style="clear:both"></div>
</div>
</ItemTemplate>
</asp:Repeater>
</ul>
<web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="user.list"
SelectCommandAutoPageWrap="true" DefaultSortExpression="orderAsc ASC">
</web:SmartSqlDataSource>
</div>
</div>
<script type="text/javascript">
var orgId = '<%=Request.Params["OrgId"] %>';
function openAllEditor(_this, action) {
var url;
var params = { FormViewMode: action };
if (action == "Edit") {
url = Global.contextPath + "/Modules/SecurityConsole/User/UserContactsView.aspx";
params.title = "编辑用户信息";
params.Id = _this.attributes["_KeyId"].value;
}
else if (action == "View") {
url = Global.contextPath + "/Modules/SecurityConsole/User/UserContactsView.aspx";
params.title = "查看用户信息";
params.Id = _this.attributes["_keyid"].value;
}
var returnValue = ShowTopDialogPopup(buildUrl(url, params), params.title, 740, 343, function (e) { window.location.reload(); });
return false;
}
function ListRefresh() {
$("#<%=btnSearch.ClientID %>").click();
}
</script>
</asp:Content>
后台代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bingosoft.Security.Web.UI;
namespace QASupervision.Modules.SecurityConsole.User
{
[UISecurity]
public partial class UserContactsList : System.Web.UI.Page
{
protected override void OnInit(EventArgs e)
{
this.GridSearch.Searching += new EventHandler(GridSearch_Searching); //这里注册新的数据查询事件
this.GridSearch.SearchReplenish += new Shared.UserControls.GridViewSearch.SearchEventHandler(GridSearch_SearchReplenish); //这里注册新的数据查询事件
base.OnInit(e);
}
void GridSearch_SearchReplenish()
{
BindData();
}
void GridSearch_Searching(object sender, EventArgs e)
{
BindData();
}
protected void BindData()
{
rpUserList.DataSourceID = "";
rpUserList.DataSource = SmartDataSource1;
DataBind();
}
protected void SearchGrid(object sender, EventArgs e)
{
this.GridSearch.Search();
}
protected void RefreshGrid(object sender, EventArgs e)
{
this.GridSearch.Refresh();
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
}