2013年4月10日

十一、一些有用的SQL查询语句

摘要: 1、 将一个表的一些字段插入到另一个表中。Insert Into 表1(表1字段1,表1字段2) Selecet 表2字段1,表2字段2 from 表2INSERT INTO Tongji (TongjiMajorID, TongjiMajorSumScore, TongjiMajorPerson)SELECT ReviewMajorID, AVG(ReviewSumScore) AS Expr1, COUNT(*) AS Expr2FROM tbReviewGROUP BY ReviewMajorID2、 在一个表增加一个另一个表的字段第一种方法:update 表1 set 表1的字段=表2 阅读全文

posted @ 2013-04-10 23:43 众里寻他千万度 阅读(196) 评论(0) 推荐(0)

十、初学.NET—GridView绑定多表字段

摘要: 使用多表左联接、右联接、内联 或者是Where字句将查询结果绑定到GridView上。多表结果也可以绑定到其它控件上。后台代码:private void SetBind() { DataSet ds = new DataSet(); using (SqlConnection conn = new SqlConnection(sConnectionString)) { SqlDataAdapter da = new SqlDataAdapter("SELECT tbReview.ReviewSubmmitState, tbMajor.MajorID, tbMajor.MajorName 阅读全文

posted @ 2013-04-10 19:11 众里寻他千万度 阅读(235) 评论(0) 推荐(0)

九、初学.NET—GridView控件页脚显示总记数、当前页码、总页码

摘要: 获得总记录数有两种方法:第一种方式:在绑定方法中ds.Tables[0].Rows.Count;中的表格行数获得private void SetBind() { DataSet ds = new DataSet(); using (SqlConnection conn = new SqlConnection(sConnectionString)) { SqlDataAdapter da = new SqlDataAdapter("SELECT tbMajor.MajorID, tbMajor.MajorName, tbDepartment.DepartmentName, tbUser 阅读全文

posted @ 2013-04-10 19:09 众里寻他千万度 阅读(360) 评论(0) 推荐(0)

八、初学.NET—GridView 中实现每一行的编辑、删除和更新语句,并且编辑模式绑定下拉框或者单选框。

摘要: 前端:在设计视图中 添加新列,选择CommandField ,选择按钮类型和命令按钮。<asp:CommandField HeaderText="编辑" ShowEditButton="True" ShowHeader="True" />给每个模板列增加编辑模板//普通文本编辑模板<asp:TemplateField HeaderText="专业名称" SortExpression="MajorName"> <EditItemTemplate> <asp 阅读全文

posted @ 2013-04-10 19:08 众里寻他千万度 阅读(401) 评论(2) 推荐(0)

七、初学.NET—GridView中添加行按钮实现查看详细信息

摘要: 前端:将需要跳转的页面中GridView中设置成模板列,使用HyperLink 的Navigate属性的第一个参数绑定数据,第二个是格式化参数实现页面跳转。<asp:TemplateField HeaderText="用户名" SortExpression="UserName"> <ItemTemplate> <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%#Eval("UserID&qu 阅读全文

posted @ 2013-04-10 19:07 众里寻他千万度 阅读(322) 评论(0) 推荐(0)

六、初学.NET—GridView每行添加提交按钮,提交后不能再次评审。

摘要: 前端:1、 给GridView中添加一模板列,将数据(ID)直接绑定到按钮的CommandArgument中,在RowCommand事件中的e.CommandArguemnt就能读出绑定的数据了。这样只能绑定一个数据。 要实现多数据绑定,通过CommandArgument=<’Container.DataItemIndex’>绑定行的索引号。2、要实现不能重复提交,要使用LinkButton 的Enabled属性使用后台方法进行格式化,返回True或者False。<asp:TemplateField HeaderText="基本操作> <ItemTemp 阅读全文

posted @ 2013-04-10 19:04 众里寻他千万度 阅读(258) 评论(0) 推荐(0)

五、初学.NET—Gridview自动编号和鼠标停留行加背景

摘要: 前端:在GridView中添加一普通绑定列<asp:BoundField HeaderText="序号" ItemStyle-Width="60px"><ItemStyle Width="60px"></ItemStyle> </asp:BoundField>后台:通过RowDataBound事件处理代码后台绑定,鼠标停留一行加背景protected void gv_ReviewOption_RowDataBound(object sender, GridViewRowEventArgs 阅读全文

posted @ 2013-04-10 19:01 众里寻他千万度 阅读(185) 评论(0) 推荐(0)

四、初学.NET—Gridview外部按钮选中、删除一行

摘要: 前端:.apx首先:设置GridView的DataKeyNames属性字段为数据表的主键<asp:GridView ID="gv_ReviewOption" runat="server" AutoGenerateColumns="False" DataKeyNames="ReviewOptionID" />在GridView中添加一模板列:<asp:TemplateField HeaderText="选择" ItemStyle-Width="60px"> 阅读全文

posted @ 2013-04-10 18:58 众里寻他千万度 阅读(378) 评论(0) 推荐(0)

三、初学.NET—Gridview的分页

摘要: 前端:.aspx首先在GridView中启用分页<asp:GridView ID="gv_ReviewIndex" runat="server" AllowPaging="True" />设置分页模式,可以在IDE环境中操作<PagerSettings FirstPageText="首页" LastPageText="末页" Mode="NextPreviousFirstLast" NextPageText="下一页" PreviousP 阅读全文

posted @ 2013-04-10 18:57 众里寻他千万度 阅读(173) 评论(0) 推荐(0)

二、初学.NET—Gridview的排序

摘要: 前端:.aspx首先设置GirdView的AllowSorting属性为True<asp:GridView ID="gv_ReviewIndex" runat="server" AllowPaging="True" AllowSorting="True" />每一列,包括模板列设置SortExpression需要排序的字段名<asp:TemplateField HeaderText="评审分数" SortExpression="ReviewSumScore" 阅读全文

posted @ 2013-04-10 18:56 众里寻他千万度 阅读(208) 评论(0) 推荐(0)

一、初学.NET—数据库连接字符串

摘要: (一)、连接SQL Server字符串的几种方式(1)信任模式1、sConnectionString=@”Server=(local);Database=数据库名;Trusted_Connection=True;”2、sConnectionString=@”Data Source=(local);Initial Catalog=数据库名;Integragrated Security=SSPI”(2)身份验证模式:1、sConnectionString=@”Server=(local);DataBase=数据库名; ;User ID=sa;Password=sa;”2、sConnectionSt 阅读全文

posted @ 2013-04-10 18:55 众里寻他千万度 阅读(271) 评论(0) 推荐(0)

导航