System.Web.UI.Page”并不包含“DataItem”的定义
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="edit_admin_datum.aspx.cs" Inherits="admin_admin_edit_admin_datum" %>
<%@ Import Namespace="System.Data"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>管理员资料修改-YY3721</title>
<link href="../style/sys_edit_admin.css" rel="stylesheet" type="text/css"/>
</head>
<body bgcolor="#9CC7EF">
<form id="form1" runat="server" action="edit_admin_datum.aspx">
<table width="70%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<td height="40" colspan="2"> <span class="add_manage_title"> 修改管理员 <span class="edit_admin_title">
<%# DataBinder.Eval(Container.DataItem, "Admin_name")%>
</span> 资料</span></td>
</tr>
<tr align="center">
<td height="30" style="width: 441px" align="right">帐号:</td>
<td width="474" height="30" colspan="-1" align="left">
<input id="Text1" type="text" value=" <%# DataBinder.Eval(Container.DataItem, "Admin_name")%>" /> </td>
</tr>
<tr align="center">
<td height="30" style="width: 441px" align="right">
密码:</td>
<td height="30" colspan="-1" align="left">
<input id="Text2" type="text" value=" <%# DataBinder.Eval(Container.DataItem, "Admin_name")%>" /> </td>
</tr>
<tr align="center">
<td height="30" style="width: 441px" align="right">权限:</td>
<td height="30" colspan="-1" align="left">
<asp:Label ID="lbl_level" runat="server" Text="Label"></asp:Label> </td>
</tr>
<tr align="center">
<td colspan="2" style="height: 30px" align="center">
<asp:Button ID="Button1" runat="server" Text="提 交" OnClick="Button1_Click" />
<input id="Button2" type="button" value="取 消" /></td>
</tr>
</table>
</form>
</body>
</html>
CS:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class admin_admin_edit_admin_datum : System.Web.UI.Page
{
protected int admin_id;
protected string str_sql;
protected SqlConnection con_id;
protected SqlDataReader sdr_id;
protected SqlCommand cmd_id;
//protected DataSet ds_id;
protected void Page_Load(object sender, EventArgs e)
{
admin_id = Convert.ToInt32(Request.QueryString["Admin_id"]);
admin_id = 1;
if (isNumeric(admin_id.ToString()))
{
str_sql = "select Admin_id,Admin_name,Admin_pwd,Admin_level from admin where admin_id = '" + admin_id + "'";
con_id = new SqlConnection(ConfigurationSettings.AppSettings["Str_sql"]);
con_id.Open();
cmd_id = new SqlCommand(str_sql, con_id);
sdr_id = cmd_id.ExecuteReader();
// lbl_level.Text = sdr_id.GetInt32(3).ToString();
Page.DataBind();
con_id.Close();
}
else
{
Response.Write("<script>alert('无效参数');</script>");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
}
private bool isNumeric(string str) //判断传入的是否数字
{
if (str == null || str.Length == 0)
return false;
System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();
byte[] bytestr = ascii.GetBytes(str);
foreach (byte c in bytestr)
{
if (c < 48 || c > 57)
{
return false;
}
}
return true;
}
}
相关推荐
Repeater绑定dictionary数据源代码及报错解决
为大家讲解下Repeater绑定dictionary数据源以及报错处理的方法,感兴趣的朋友可以参考下哈,希望对你有所帮助
datalist分页方法
datalist分页方法 介绍datalist简单分页和数据绑定的方法
C#自定义分页控件
一、AspNetPager支持两种方式分页: 一种是PostBack方式分页, 一种是通过Url来实现分页以及Url重写功能 二、AspNetPager支持各种数据绑定控件GridView、DataGrid、DataList、Repeater以及自定义的数据绑定控件的分页功能十分强大。 三、AspNetPager分页控件本身并不显示任何数据,而只显示分页导航元素,数据在页面上的显示方式与该控件无关,所以需要手写数据连接方法来配合, 四、结合TOP 。。。NOT IN 的通用存储过程分页方法使用AspNetPager十分实用 测试控件datalist aspnetpager 的分页方法示例 分页方法为 PostBack 方式 1、 首先将AspNetPager.dll复制于应用程序下的bin目录,打开解决方案,引入dll文件 2、 在工具栏中添加控件,这样可以支持拖拽使用 3、 要使用AspNetPager 要为其设置最基本的属性 使用 SqlServer Northwind数据库的 Products表 protected Wuqi.Webdiyer.AspNetPager AspNetPager1; protected System.Web.UI.WebControls.Label Label1; protected System.Web.UI.WebControls.DataList DataList1; private void Page_Load(object sender, System.EventArgs e) { this.AspNetPager1.PageSize=10; //设置每也显示的记录条数 if(!IsPostBack) //只在页面第一次加载时起作用 { SqlDBManager db = new SqlDBManager(System.Configuration.ConfigurationSettings.AppSettings["SqlConnectionString"]); AspNetPager1.RecordCount=db.CountPage("products");//获得要使用表的记录总数 //db.CountItems自定义的方法 this.BindData(); } } private void BindData() { SqlDBManager db= new SqlDBManager(System.Configuration.ConfigurationSettings.AppSettings["SqlConnectionString"].ToString(); DataList1.DataSource=db.FenPage(this.AspNetPager1.PageSize,this.AspNetPager1.CurrentPageIndex,"productid","products","productid,productname,unitprice,unitsinstock",""); //自定义方法由 TOP not in 存储过程分页方法改编 this.DataList1.DataBind(); //控件数据绑定 this.Label1.Text="当前第"+this.AspNetPager1.CurrentPageIndex+"页 总"+this.AspNetPager1.PageCount+"页"; } private void AspNetPager1_PageChanged(object sender, System.EventArgs e) { //页索引改变方法 this.BindData(); } 设计页效果 <asp:DataList id="DataList1" style="Z-INDEX: 101; LEFT: 296px; POSITION: absolute; TOP: 96px" runat="server"> <HeaderTemplate> <table border='1'> <tr> <td>产品ID</td> <td>产品名称</td> <td>产品数量</td> <td>产品单价</td> </tr> </HeaderTemplate> <FooterTemplate> </table> </FooterTemplate> <ItemTemplate> <tr> <td><%# DataBinder.Eval(Container.DataItem,"Productid")%></td> <td><%# DataBinder.Eval(Container.DataItem,"productname")%></td> <td><%# DataBinder.Eval(Container.DataItem,"unitprice")%></td> <td><%# DataBinder.Eval(Container.DataItem,"unitsinstock")%></td> </tr> </ItemTemplate> </asp:DataList> <webdiyer:AspNetPager id="AspNetPager1" style="Z-INDEX: 102; LEFT: 256px; POSITION: absolute; TOP: 40px" runat="server" Width="500px" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" Height="40px" NumericButt PagingButt ShowNavigati ShowInputBox="Always" TextAfterInputBox="页" TextBeforeInputBox="跳转到第" AlwaysShow="True"> </webdiyer:AspNetPager> <asp:Label id="Label1" style="Z-INDEX: 103; LEFT: 120px; POSITION: absolute; TOP: 56px" runat="server">Label</asp:Label>
GridView突出显示某一单元格(例如金额低于多少,分数不及格等
GridView突出显示某一单元格(例如金额低于多少,分数不及格等
C# 将数据导出到Excel汇总
C# 将数据 导出到Excel的教程,包括datagrid datalist等。


