欢迎来到天天文库
浏览记录
ID:39803577
大小:21.26 KB
页数:14页
时间:2019-07-11
《做收藏遇到问题》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、收藏功能问题收藏的ALLItems页面用了Datalist做;因此没有系统自带分页,只能自己写分页功能;#region这是收藏后台代码usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingWeb.Common;usingSystem.Data;usingSystem.Data.SqlClient;usingSystem.Confi
2、guration;namespaceWeb.Collections.UserControl{publicpartialclassWUCGrid:BasedUserControl{protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){ViewState["pageindex"]=0;BindData();}}privateint_ArticleID;publicintArticleID{get{return_ArticleID;}set{_ArticleID=val
3、ue;}}protectedvoidlnkBtnTitle_Click(objectsender,EventArgse){LinkButtonlnkBtnTitle=(LinkButton)sender;if(lnkBtnTitle!=null){ArticleID=Convert.ToInt32(lnkBtnTitle.CommandArgument);}//查询对应的ArticleID的ispublic是否为1;为公开;eSchool.JXKYW.Library.Articlesarticles=(frompinDataContex
4、t.Articleswherep.ID.Equals(ArticleID)&&p.IsPublic.Equals(1)&&p.UsedFlag.Equals(1)selectp).FirstOrDefault();if(articles==null){thrownewException("文章已被删除!");}}protectedvoiddl_DataBinding(objectsender,EventArgse){}//删除事件protectedvoiddl_DeleteCommand(objectsource,DataListCom
5、mandEventArgse){intKey=Convert.ToInt32(dl.DataKeys[e.Item.ItemIndex].ToString());//获取激发事件时的行的主键IDStringconString=ConfigurationManager.ConnectionStrings["JXKYWConnectionString"].ConnectionString;StringstrSql="deletefromCollectionswhereID='"+Key+"'";introws=ExecuteSql(strS
6、ql,conString);BindData();}publicintExecuteSql(stringstrSql,stringconString){using(SqlConnectionmyConnection=newSqlConnection(conString)){using(SqlCommandcmd=newSqlCommand(strSql,myConnection)){myConnection.Open();introws=cmd.ExecuteNonQuery();returnrows;}}}#regionDataLis
7、t分页publicstaticDataSetGetTable(stringsql){SqlConnectionconn=newSqlConnection(ConfigurationManager.ConnectionStrings["JXKYWConnectionString"].ConnectionString);SqlDataAdapterda=newSqlDataAdapter(sql,conn);DataSetds=newDataSet();da.Fill(ds);returnds;}publicvoidBindData(){s
8、tringLoginName=this.CurrentLoginName;stringsql="select*fromvw_CollectionsArticleswhereCollectorName='"+
此文档下载收益归作者所有