1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserList.aspx.cs" Inherits="TopWin.DongFengYL.SQLMemberShip.WebCtrl._layout.WebForm2" %> 2 <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %> 3 <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 5 <html xmlns="http://www.w3.org/1999/xhtml"> 6 <head id="Head1" runat="server"> 7 <title>用户编辑</title> 8 <style type="text/css"> 9 body{ font-size:12px;} 10 </style> 11 </head> 12 <body> 13 <form id="form1" runat="server"> 14 <asp:ScriptManager runat="server" ID="sm1"></asp:ScriptManager> 15 <div> 16 <div class="RadGrid RadGrid_Default"> 17 <table cellspacing="0" class="rgMasterTable" style="width:100%;table-layout:auto;empty-cells:show;"> 18 <tr class="rgRow" > 19 <td style=" text-align:left; margin-left:20px;"><a href="UserInfo.aspx">添加信息</a></td> 20 </tr> 21 </table> 22 </div> 23 <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" 24 AllowPaging="True" PageSize="20" AllowSorting="True" AutoGenerateColumns="false" 25 ShowStatusBar="false" AllowAutomaticDeletes="True" AllowAutomaticInserts="false" 26 AllowAutomaticUpdates="false" HorizontalAlign="NotSet" ondeletecommand="RadGrid1_DeleteCommand" onupdatecommand="RadGrid1_UpdateCommand" 27 onneeddatasource="RadGrid1_NeedDataSource"> 28 <MasterTableView CommandItemDisplay="none" DataKeyNames="UserName" EditMode="PopUp"> 29 <Columns> 30 31 <telerik:GridBoundColumn UniqueName="UserDispName" HeaderText="昵称" DataField="UserDispName"> 32 <HeaderStyle Width="60px"></HeaderStyle> 33 </telerik:GridBoundColumn> 34 <telerik:GridBoundColumn UniqueName="CompanyName" HeaderText="公司名称" DataField="CompanyName"> 35 </telerik:GridBoundColumn> 36 <telerik:GridBoundColumn UniqueName="DeptName" HeaderText="部门名称" DataField="DeptName"> 37 </telerik:GridBoundColumn> 38 <telerik:GridBoundColumn UniqueName="Tel" HeaderText="电话" DataField="Tel"> 39 </telerik:GridBoundColumn> 40 <telerik:GridBoundColumn UniqueName="Mobile" HeaderText="手机" DataField="Mobile"> 41 </telerik:GridBoundColumn> 42 <telerik:GridBoundColumn UniqueName="Description" HeaderText="描述" DataField="Description"> 43 </telerik:GridBoundColumn> 44 <telerik:GridButtonColumn CommandName="Delete" Text="删除" ConfirmText="确定删除吗?" UniqueName="column"> 45 </telerik:GridButtonColumn> 46 <telerik:GridButtonColumn CommandName="update" Text="修改" UniqueName="column"> 47 </telerik:GridButtonColumn> 48 </Columns> 49 <PagerStyle FirstPageToolTip="首页" LastPageToolTip="尾页" NextPagesToolTip="下一页" 50 NextPageToolTip="下一页" 51 PageSizeLabelText="页数:" PrevPagesToolTip="上一页" PrevPageToolTip="上一页" /> 52 </MasterTableView> 53 </telerik:RadGrid> 54 </div> 55 </form> 56 </body> 57 </html>
public partial class WebForm2 : System.Web.UI.Page
{
private UserBAO bao = null;
protected void Page_Load(object sender, EventArgs e)
{
}
public DataSet GetDYUserExtInfoFata
{
get
{
bao = new UserBAO();
if (bao.GetDYUserExtInfoFata() != null)
{
return bao.GetDYUserExtInfoFata();
}
else
{
return null;
}
}
}
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
this.RadGrid1.DataSource = GetDYUserExtInfoFata;
//this.GetDYUserExtInfoFata.Tables[0].PrimaryKey = new DataColumn[] { this.GetDYUserExtInfoFata.Tables[0].Columns["UserName"] };//设置主键
}
protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)
{
string userName = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["UserName"].ToString();
bao = new UserBAO();
if (bao.DeleteUser(userName) > 0)
{
CommonFunction.ShowMessage(this.Page, "删除成功!", "UserList.aspx");
}
else
{
CommonFunction.ShowMessage(this.Page, "删除失败!", "UserList.aspx");
}
}
protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
string userName = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["UserName"].ToString();
Response.Redirect("UserInfo.aspx?account=" + userName + "");
}