| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3035 人关注过本帖
标题:怎样把查询按钮中的结果在gridview中显示出来(新手问题)
只看楼主 加入收藏
stonefang
Rank: 1
等 级:新手上路
帖 子:163
专家分:0
注 册:2007-3-20
收藏
 问题点数:0 回复次数:10 
怎样把查询按钮中的结果在gridview中显示出来(新手问题)

Yexhn27u.rar (251.26 KB) 怎样把查询按钮中的结果在gridview中显示出来(新手问题)


我是.NET的初学者,在做学生管理系统的教师管理时,遇到的问题是不会做查询,请高手们帮忙解决一下,先谢了,下面是页面的代码.压缩包里是全部内容.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="St_teacher.aspx.cs" Inherits="St_teacher" %>
<!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">
<link href="../SiteMap/body.css" rel="stylesheet" type="text/css"/>
<title>教师信息管理</title>
</head>
<body alink="#66ccff" bgcolor="#ccccff" link="blue" text="black" vlink="#cc6600" style="text-align: center">
<form id="form1" runat="server">
<div>
&nbsp;</div>
<table border="1" style="width: 728px; height: 99px">
<tr>
<td colspan="6" style="background-color: #cc99cc; height: 29px; text-align: center; width: 711px;">
教师信息管理&nbsp; 教师名:<asp:TextBox ID="st_tbx_tname" runat="server"></asp:TextBox>教师编号:<asp:TextBox
ID="st_tbx_tid" runat="server"></asp:TextBox>
<asp:Button ID="st_btn_search" runat="server" Text="查询" OnClick="st_btn_search_Click" /></td>
</tr>
<tr>
<td style="background-color: #cc99cc; width: 711px; text-align: center;" colspan="6" rowspan="2">
<asp:GridView ID="gridv_t" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="ST_Teacher_id" DataSourceID="SqlDS_t"
Height="100%" Width="100%" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3">
<Columns>
<asp:BoundField DataField="ST_Teacher_id" HeaderText="教师号" ReadOnly="True" SortExpression="ST_Teacher_id" />
<asp:BoundField DataField="ST_Teacher_name" HeaderText="教师姓名" SortExpression="ST_Teacher_name" />
<asp:BoundField DataField="ST_Teacher_college" HeaderText="学院" SortExpression="ST_Teacher_college" />
<asp:HyperLinkField HeaderText="加为管理员" DataTextField="ST_Teacher_id" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
</Columns>
<FooterStyle BackColor="White" ForeColor="#000066" />
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<br />
<asp:SqlDataSource ID="SqlDS_t" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:st_dbconn %>" DeleteCommand="DELETE FROM [ST_teacher] WHERE [ST_Teacher_id] = @original_ST_Teacher_id AND [ST_Teacher_name] = @original_ST_Teacher_name AND [ST_Teacher_college] = @original_ST_Teacher_college"
InsertCommand="INSERT INTO [ST_teacher] ([ST_Teacher_id], [ST_Teacher_name], [ST_Teacher_college]) VALUES (@ST_Teacher_id, @ST_Teacher_name, @ST_Teacher_college)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [ST_teacher] ORDER BY [ST_Teacher_id], [ST_Teacher_name] DESC"
UpdateCommand="UPDATE [ST_teacher] SET [ST_Teacher_name] = @ST_Teacher_name, [ST_Teacher_college] = @ST_Teacher_college WHERE [ST_Teacher_id] = @original_ST_Teacher_id AND [ST_Teacher_name] = @original_ST_Teacher_name AND [ST_Teacher_college] = @original_ST_Teacher_college">
<DeleteParameters>
<asp:Parameter Name="original_ST_Teacher_id" Type="String" />
<asp:Parameter Name="original_ST_Teacher_name" Type="String" />
<asp:Parameter Name="original_ST_Teacher_college" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ST_Teacher_name" Type="String" />
<asp:Parameter Name="ST_Teacher_college" Type="String" />
<asp:Parameter Name="original_ST_Teacher_id" Type="String" />
<asp:Parameter Name="original_ST_Teacher_name" Type="String" />
<asp:Parameter Name="original_ST_Teacher_college" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ST_Teacher_id" Type="String" />
<asp:Parameter Name="ST_Teacher_name" Type="String" />
<asp:Parameter Name="ST_Teacher_college" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</td>
</tr>
<tr>
</tr>
<tr>
<td colspan="6" style="height: 23px; background-color: #cc99cc; text-align: center; width: 711px;">
添加新教师 &nbsp; &nbsp;管理员列表 &nbsp; 教师个人密码修改<br />
<asp:Button ID="st_btn_exit" runat="server" Text="退出" OnClick="st_btn_exit_Click" />
<asp:Label ID="st_lab_teach" runat="server" Text="Label_tea" Visible="False"></asp:Label></td>
</tr>
</table>
</form>
</body>
</html>


搜索更多相关主题的帖子: gridview 按钮 结果 查询 
2007-04-28 22:58
airfei
Rank: 1
等 级:新手上路
帖 子:137
专家分:0
注 册:2007-4-12
收藏
得分:0 
你可以记录下查询条件,然后在查询按钮事件中根据记录来帮定dataview的字段就可以了
2007-04-29 04:16
IPV6
Rank: 1
等 级:新手上路
威 望:2
帖 子:265
专家分:0
注 册:2006-9-7
收藏
得分:0 
在按钮事件st_btn_search_Click中加入dataview绑定代码,就可以了

2007-04-29 08:56
stonefang
Rank: 1
等 级:新手上路
帖 子:163
专家分:0
注 册:2007-3-20
收藏
得分:0 

我在"查询"按钮事件下写的代码,就是不能完成查询功能,请看看怎样改.
protected void st_btn_search_Click(object sender, EventArgs e)
{
st_sqlstr = "select * from ST_teacher where ST_Teacher_id='" + st_tbx_tid.Text + "' or ST_Teacher_name='" + st_tbx_tname.Text + "'";
SqlDataAdapter st_da = new SqlDataAdapter(st_sqlstr, st_conn);
DataSet st_ds = new DataSet();
st_da.Fill(st_ds);
gv_teach.DataSource = st_ds;
gv_teach.DataBind();

}


我就是我! 从那跌到从那爬起! E-mail:fangguang2008@
2007-04-29 20:36
beniao
Rank: 2
等 级:新手上路
威 望:4
帖 子:367
专家分:2
注 册:2004-12-17
收藏
得分:0 
应该没错啊```

博客:http://
2007-05-14 19:04
airfei
Rank: 1
等 级:新手上路
帖 子:137
专家分:0
注 册:2007-4-12
收藏
得分:0 
st_conn,没有打开数据库连接
sqlconnecting con =new sqlconnecting("server=.;database=***;uid=sa;pwd=;");
con.open();
2007-05-15 01:09
tel1982
Rank: 3Rank: 3
来 自:水星
等 级:新手上路
威 望:8
帖 子:852
专家分:0
注 册:2006-10-21
收藏
得分:0 
是呀,你打开是据库连接了吗?

Face up to life with smiles no matter what happens
2007-05-15 07:30
stonefang
Rank: 1
等 级:新手上路
帖 子:163
专家分:0
注 册:2007-3-20
收藏
得分:0 
解决了,多谢提示.

我就是我! 从那跌到从那爬起! E-mail:fangguang2008@
2007-05-15 16:58
stonefang
Rank: 1
等 级:新手上路
帖 子:163
专家分:0
注 册:2007-3-20
收藏
得分:0 
tel1982我加你的群怎么加不进去?

我就是我! 从那跌到从那爬起! E-mail:fangguang2008@
2007-05-15 17:03
tel1982
Rank: 3Rank: 3
来 自:水星
等 级:新手上路
威 望:8
帖 子:852
专家分:0
注 册:2006-10-21
收藏
得分:0 
再加一下,我在学校里,网速比较慢。

Face up to life with smiles no matter what happens
2007-05-15 22:27
快速回复:怎样把查询按钮中的结果在gridview中显示出来(新手问题)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032788 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved