如何将通过教师ID查询到的信息放到各个教师信息的textbox中? 这个信息包括姓名,民族,学部,性别,邮箱等等~这个过程应该会用到绑定和刷新页面吧,那个 查询栏和教师信息部分是在一个页面的哪位能给个例子吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我是这样写的://page_load 这里是按教师编号查询教师信息 string sql = "select teacher_id,teacher_name,teacher_sex,teacher_marr," + "teacher_nation,teacher_type,teacher_zc,teacher_zw," + "telephone,address,dept_id,dept_name,xishi_id,xishi_name" + "from xishi_info,dept_info,teacher_info" + "where teacher_id=tb1.text";//查询button下调用数据库数据,并用databind绑定textbox SqlConnection cn = new SqlConnection("Data Source=localhost;" + "Integrated Security=SSPI;Initial Catslog=db_keyan"); SqlCommand cm = new SqlCommand("sql", cn); teach_name.DataBind(); teach_sex.DataBind(); teach_marr.DataBind(); tea_jg.DataBind(); teacher_nation.DataBind();//有两个属性是用的dropdownlist,再在其相应的函数体下写绑定语句:(这个是网上找的) if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DropDownList dd = (DropDownList)e.Item.FindControl("DropDownListID"); //................. dd.DataTextField = "name"; dd.DataValueField = "id"; dd.DataSource = ds; dd.DataBind(); }问题是 在最后一条里面 e.Item.ItemType中间这个Item说是System.EventArgs不包含它的定义,并且找不到可接受类型为 System.EventArgs的第一个参数的扩展方法等等。。想问一下:1、针对我的问题,我的思路对吗?2、这个Item表示的是什么?3、还有,dd.DataSource = ds;这句的ds代表的不是我调用的那个数据库的名字吗?那是什么?刚真正接触这方面的,很多还是不懂,迷迷糊糊的就请各位帮帮忙了~~ teach_name.DataBind(); teach_sex.DataBind(); teach_marr.DataBind(); tea_jg.DataBind(); teacher_nation.DataBind();这个不是这样用的。VS有自动感知功能,你这肯定是手打的或复制的。只有控件才有这种属性。顺便给你源代码,下面是后台的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;public partial class DeanAdmin_CourWareDetail : System.Web.UI.Page{ string noPermissionPage = Utility.mainUrl + "Users/NoPermission.aspx";//无权访问页面 string id = string.Empty; protected void Page_Load(object sender, EventArgs e) { if (Session["RoleID"] != null) { if (Request.QueryString.Count > 0) { id = ClEas.Public.Encrypt.DecryptDES(Request.QueryString[0].Trim()); BindDataInit(); } } else { Response.Redirect(Utility.loginPage + Utility.GetPageUrl());//返回登录页面 } } private void BindDataInit() { CourWare courware = new CourWare(); DataTable dt = courware.GetCourInfo(id); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; if (Convert.ToBoolean(dr["OpenFlag"]) || Session["RoleID"].ToString() == "40" || Session["RoleID"].ToString() == "30" || Session["UserID"].ToString() == dr["LeaderID"].ToString()) { lbCourID.Text = dr["CourID"].ToString(); lbCourName.Text = this.Title = dr["CourName"].ToString() + "优秀课件展示"; lbCour.Text = dr["CourName"].ToString(); lbDeptName.Text = dr["DeptName"].ToString(); lbFirstSubjectName.Text = dr["FirstSubjectName"].ToString(); lbSecondSubjectName.Text = dr["SecondSubjectName"].ToString(); lbLeaderName.Text = dr["LeaderName"].ToString(); lbStaffName.Text = dr["StaffName"].ToString(); lbContent.Text = dr["CourMemo"].ToString(); lbItemStae.Text = dr["State"].ToString(); if (dr["SyllUrl"].ToString() != string.Empty) { hlSyllUrl.NavigateUrl = Utility.mainUrl + Utility.attrPath + "DownLoad.aspx?attrPath=" + ClEas.Public.Encrypt.EncryptDES("CourWare/" + dr["SyllUrl"].ToString()); hlSyllUrl.Target = "_blank"; } if (dr["CourWareUrl"].ToString() != string.Empty) { hlCourWare.NavigateUrl = Utility.mainUrl + Utility.attrPath + "DownLoad.aspx?attrPath=" + ClEas.Public.Encrypt.EncryptDES("CourWare/" + dr["CourWareUrl"].ToString()); hlCourWare.Target = "_blank"; } } else { Response.Write("<script language='javascript'>alert('课件不对外公开'); window.close(); </script>"); } } else { Response.Write("<script language='javascript'>alert('课件不存在'); window.close(); </script>"); } }}下面是前台的。<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CourWareDetail.aspx.cs" Inherits="DeanAdmin_CourWareDetail" %><%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %><!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>无标题页</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div class="SinglePage"> <div class="Text-Center"> <h3> <asp:Label ID="lbCourName" runat="server" ></asp:Label></h3> </div> <asp:Panel ID="CourInfo" Width="600px" runat="server"> <table style="width: 600px; height: 80px"> <tr> <td style="width: 80px"> 课程名称: </td> <td style="width: 120px"> <asp:Label ID="lbCour" runat="server"></asp:Label> </td> <td style="width: 80px"> 课程编号: </td> <td style="width: 120px"> <asp:Label ID="lbCourID" runat="server" ></asp:Label> </td> <td style="width: 80px"> 所属院系: </td> <td style="width: 120px"> <asp:Label ID="lbDeptName" runat="server" ></asp:Label> </td> </tr> <tr> <td style="width: 80px"> 一级学科: </td> <td> <asp:Label ID="lbFirstSubjectName" runat="server" ></asp:Label> </td> <td style="width: 80px"> 二级学科: </td> <td> <asp:Label ID="lbSecondSubjectName" runat="server" ></asp:Label> </td> <td style="width: 80px"> 负责人: </td> <td> <asp:Label ID="lbLeaderName" runat="server" ></asp:Label> </td> </tr> <tr> <td style="width: 80px"> 成员: </td> <td colspan="3"> <asp:Label ID="lbStaffName" runat="server" ></asp:Label> </td> <td style="width: 80px"> 审核状态: </td> <td> <asp:Label ID="lbItemStae" runat="server" ></asp:Label> </td> </tr> <tr> <td style="width: 80px"> <asp:HyperLink ID="hlCourWare" CssClass="strong" runat="server">课件下载</asp:HyperLink> </td> <td> <asp:HyperLink ID="hlSyllUrl" CssClass="strong" runat="server">大纲下载</asp:HyperLink> </td> <td style="width: 80px"> </td> <td> </td> <td style="width: 80px"> </td> <td> </td> </tr> </table> </asp:Panel> <br /> <h4>课件简介</h4> <asp:Panel ID="CourContent" runat="server" Height="400" Width="600"> <br /> <asp:Literal ID="lbContent" runat="server"></asp:Literal> </asp:Panel> <asp:RoundedCornersExtender ID="RoundedCornersExtender1" runat="server" TargetControlID="CourContent" BorderColor="#3D8466" Radius="6" Corners="All" /> <asp:RoundedCornersExtender ID="RoundedCornersExtender2" runat="server" TargetControlID="CourInfo" BorderColor="#3D8466" Radius="6" Corners="All" /> </div> </form></body></html> 如果是GridView,则首先将GridView实例化。WEB下,将该GridView放入页面中,一般会命名GridView1,在后台中,使用实例名GridView1.datasource = DataTable;这个DataTable表示ds中的一个表也可以是你自己构造的一个表。GridView1.databind();综合来讲,楼主基础不足,有些基础是很难讲的,建议先找书看。 使用mono实现脱离.net框架后程序无法访问网络了 如何C#获取一个真随机数? 取出SRC地址来? 通过使用 sqlmdo 完成数据库恢复后的一小段时间由于关闭了数据库的所有进程 打开其他窗口时数据库操作出错 如何把所有线程重新启动 希望 关于FTP上传的问题! 关于label控件问题 需要实现这样的功能,能够按关键字搜索附件word里的内容,如果有则显示在web页中,而不是以连接方式打开 子窗体中如何设置父窗体的StatusBar的内容? c#socket 传输tcp协议,怎样获取传输的速度 简单问题 关于冒泡排序的一点! 如果将数据显示到一个公共用到的数据表格窗体?
//page_load 这里是按教师编号查询教师信息
string sql = "select teacher_id,teacher_name,teacher_sex,teacher_marr,"
+ "teacher_nation,teacher_type,teacher_zc,teacher_zw,"
+ "telephone,address,dept_id,dept_name,xishi_id,xishi_name"
+ "from xishi_info,dept_info,teacher_info" +
"where teacher_id=tb1.text";
//查询button下调用数据库数据,并用databind绑定textbox
SqlConnection cn = new SqlConnection("Data Source=localhost;" +
"Integrated Security=SSPI;Initial Catslog=db_keyan");
SqlCommand cm = new SqlCommand("sql", cn);
teach_name.DataBind();
teach_sex.DataBind();
teach_marr.DataBind();
tea_jg.DataBind();
teacher_nation.DataBind();
//有两个属性是用的dropdownlist,再在其相应的函数体下写绑定语句:(这个是网上找的)
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DropDownList dd = (DropDownList)e.Item.FindControl("DropDownListID");
//.................
dd.DataTextField = "name";
dd.DataValueField = "id";
dd.DataSource = ds;
dd.DataBind();
}
问题是 在最后一条里面 e.Item.ItemType中间这个Item说是System.EventArgs不包含它的定义,并且找不到可接受类型为 System.EventArgs的第一个参数的扩展方法等等。。
想问一下:
1、针对我的问题,我的思路对吗?
2、这个Item表示的是什么?
3、还有,dd.DataSource = ds;这句的ds代表的不是我调用的那个数据库的名字吗?那是什么?
刚真正接触这方面的,很多还是不懂,迷迷糊糊的
就请各位帮帮忙了~~
teach_sex.DataBind();
teach_marr.DataBind();
tea_jg.DataBind();
teacher_nation.DataBind();这个不是这样用的。VS有自动感知功能,你这肯定是手打的或复制的。只有控件才有这种属性。顺便给你源代码,下面是后台的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;public partial class DeanAdmin_CourWareDetail : System.Web.UI.Page
{
string noPermissionPage = Utility.mainUrl + "Users/NoPermission.aspx";//无权访问页面
string id = string.Empty; protected void Page_Load(object sender, EventArgs e)
{
if (Session["RoleID"] != null)
{ if (Request.QueryString.Count > 0)
{
id = ClEas.Public.Encrypt.DecryptDES(Request.QueryString[0].Trim());
BindDataInit();
} }
else
{
Response.Redirect(Utility.loginPage + Utility.GetPageUrl());//返回登录页面
}
} private void BindDataInit()
{
CourWare courware = new CourWare();
DataTable dt = courware.GetCourInfo(id);
if (dt.Rows.Count > 0)
{
DataRow dr = dt.Rows[0]; if (Convert.ToBoolean(dr["OpenFlag"]) || Session["RoleID"].ToString() == "40" || Session["RoleID"].ToString() == "30" || Session["UserID"].ToString() == dr["LeaderID"].ToString())
{
lbCourID.Text = dr["CourID"].ToString();
lbCourName.Text = this.Title = dr["CourName"].ToString() + "优秀课件展示";
lbCour.Text = dr["CourName"].ToString();
lbDeptName.Text = dr["DeptName"].ToString();
lbFirstSubjectName.Text = dr["FirstSubjectName"].ToString();
lbSecondSubjectName.Text = dr["SecondSubjectName"].ToString();
lbLeaderName.Text = dr["LeaderName"].ToString();
lbStaffName.Text = dr["StaffName"].ToString();
lbContent.Text = dr["CourMemo"].ToString();
lbItemStae.Text = dr["State"].ToString();
if (dr["SyllUrl"].ToString() != string.Empty)
{
hlSyllUrl.NavigateUrl = Utility.mainUrl + Utility.attrPath + "DownLoad.aspx?attrPath=" + ClEas.Public.Encrypt.EncryptDES("CourWare/" + dr["SyllUrl"].ToString());
hlSyllUrl.Target = "_blank";
}
if (dr["CourWareUrl"].ToString() != string.Empty)
{
hlCourWare.NavigateUrl = Utility.mainUrl + Utility.attrPath + "DownLoad.aspx?attrPath=" + ClEas.Public.Encrypt.EncryptDES("CourWare/" + dr["CourWareUrl"].ToString());
hlCourWare.Target = "_blank";
}
}
else
{
Response.Write("<script language='javascript'>alert('课件不对外公开'); window.close(); </script>");
}
}
else
{ Response.Write("<script language='javascript'>alert('课件不存在'); window.close(); </script>");
}
}
}下面是前台的。<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CourWareDetail.aspx.cs" Inherits="DeanAdmin_CourWareDetail" %><%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!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>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div class="SinglePage">
<div class="Text-Center">
<h3>
<asp:Label ID="lbCourName" runat="server" ></asp:Label></h3>
</div>
<asp:Panel ID="CourInfo" Width="600px" runat="server">
<table style="width: 600px; height: 80px">
<tr>
<td style="width: 80px">
课程名称:
</td>
<td style="width: 120px">
<asp:Label ID="lbCour" runat="server"></asp:Label>
</td>
<td style="width: 80px">
课程编号:
</td>
<td style="width: 120px">
<asp:Label ID="lbCourID" runat="server" ></asp:Label>
</td>
<td style="width: 80px">
所属院系:
</td>
<td style="width: 120px">
<asp:Label ID="lbDeptName" runat="server" ></asp:Label>
</td>
</tr>
<tr>
<td style="width: 80px">
一级学科:
</td>
<td>
<asp:Label ID="lbFirstSubjectName" runat="server" ></asp:Label>
</td>
<td style="width: 80px">
二级学科:
</td>
<td>
<asp:Label ID="lbSecondSubjectName" runat="server" ></asp:Label>
</td>
<td style="width: 80px">
负责人:
</td>
<td>
<asp:Label ID="lbLeaderName" runat="server" ></asp:Label>
</td>
</tr>
<tr>
<td style="width: 80px">
成员:
</td>
<td colspan="3">
<asp:Label ID="lbStaffName" runat="server" ></asp:Label>
</td>
<td style="width: 80px">
审核状态:
</td>
<td>
<asp:Label ID="lbItemStae" runat="server" ></asp:Label>
</td>
</tr>
<tr>
<td style="width: 80px">
<asp:HyperLink ID="hlCourWare" CssClass="strong" runat="server">课件下载</asp:HyperLink>
</td>
<td>
<asp:HyperLink ID="hlSyllUrl" CssClass="strong" runat="server">大纲下载</asp:HyperLink>
</td>
<td style="width: 80px">
</td>
<td>
</td>
<td style="width: 80px">
</td>
<td>
</td>
</tr>
</table>
</asp:Panel>
<br />
<h4>课件简介</h4>
<asp:Panel ID="CourContent" runat="server" Height="400" Width="600">
<br />
<asp:Literal ID="lbContent" runat="server"></asp:Literal>
</asp:Panel>
<asp:RoundedCornersExtender ID="RoundedCornersExtender1" runat="server" TargetControlID="CourContent"
BorderColor="#3D8466" Radius="6" Corners="All" />
<asp:RoundedCornersExtender ID="RoundedCornersExtender2" runat="server" TargetControlID="CourInfo"
BorderColor="#3D8466" Radius="6" Corners="All" />
</div>
</form>
</body>
</html>
GridView1.datasource = DataTable;这个DataTable表示ds中的一个表也可以是你自己构造的一个表。
GridView1.databind();综合来讲,楼主基础不足,有些基础是很难讲的,建议先找书看。