System.Web.UI.Page”并不包含“DataItem”的定义
aspx:
<%@ 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;
}
}
[解决办法]
没有数据源。