做收藏遇到问题Word下载.docx

上传人:b****6 文档编号:20171315 上传时间:2023-01-17 格式:DOCX 页数:19 大小:20.64KB
下载 相关 举报
做收藏遇到问题Word下载.docx_第1页
第1页 / 共19页
做收藏遇到问题Word下载.docx_第2页
第2页 / 共19页
做收藏遇到问题Word下载.docx_第3页
第3页 / 共19页
做收藏遇到问题Word下载.docx_第4页
第4页 / 共19页
做收藏遇到问题Word下载.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

做收藏遇到问题Word下载.docx

《做收藏遇到问题Word下载.docx》由会员分享,可在线阅读,更多相关《做收藏遇到问题Word下载.docx(19页珍藏版)》请在冰豆网上搜索。

做收藏遇到问题Word下载.docx

LinkButtonlnkBtnTitle=(LinkButton)sender;

if(lnkBtnTitle!

=null)

ArticleID=Convert.ToInt32(lnkBtnTitle.CommandArgument);

//查询对应的ArticleID的ispublic是否为1;

为公开;

eSchool.JXKYW.Library.Articlesarticles=(frompinDataContext.Articles

wherep.ID.Equals(ArticleID)&

&

p.IsPublic.Equals

(1)&

p.UsedFlag.Equals

(1)

selectp).FirstOrDefault();

if(articles==null)

thrownewException("

文章已被删除!

"

);

protectedvoiddl_DataBinding(objectsender,EventArgse)

//删除事件

protectedvoiddl_DeleteCommand(objectsource,DataListCommandEventArgse)

intKey=Convert.ToInt32(dl.DataKeys[e.Item.ItemIndex].ToString());

//获取激发事件时的行的主键ID

StringconString=ConfigurationManager.ConnectionStrings["

JXKYWConnectionString"

].ConnectionString;

StringstrSql="

deletefromCollectionswhereID='

+Key+"

'

;

introws=ExecuteSql(strSql,conString);

publicintExecuteSql(stringstrSql,stringconString)

using(SqlConnectionmyConnection=newSqlConnection(conString))

using(SqlCommandcmd=newSqlCommand(strSql,myConnection))

myConnection.Open();

introws=cmd.ExecuteNonQuery();

returnrows;

#regionDataList分页

publicstaticDataSetGetTable(stringsql)

{

SqlConnectionconn=newSqlConnection(ConfigurationManager.ConnectionStrings

["

].ConnectionString);

SqlDataAdapterda=newSqlDataAdapter(sql,conn);

DataSetds=newDataSet();

da.Fill(ds);

returnds;

publicvoidBindData()

stringLoginName=this.CurrentLoginName;

stringsql="

select*fromvw_CollectionsArticleswhereCollectorName='

+LoginName+"

DataSetobjds=GetTable(sql);

PagedDataSourceobjPds=newPagedDataSource();

objPds.DataSource=objds.Tables[0].DefaultView;

objPds.AllowPaging=true;

objPds.PageSize=10;

objPds.CurrentPageIndex=int.Parse(ViewState["

].ToString());

objPds.IsFirstPage)

lkPre.Visible=true;

else

lkPre.Visible=false;

objPds.IsLastPage)

lkNext.Visible=true;

lkNext.Visible=false;

//如果没有找到数据就隐藏pnlNoArticle

if(objPds.DataSourceCount>

0)

this.FindControl("

pnlNoArticle"

).Visible=false;

).Visible=true;

dl.DataSource=objPds;

dl.DataKeyField="

ID"

dl.DataBind();

/*上一页下一页的事件;

I两个按钮的OnCommand都是IndexChanging()函数,我们通过CommandArgument(pre和next)来区分到底是向前翻还是向后翻。

下面是IndexChanging()函数*/

protectedvoidIndexChanging(objectsender,EventArgse)

stringstrCommand=((LinkButton)sender).CommandArgument.ToString();

//得到linkbtn的CommandArgument值

intpageindex=int.Parse(ViewState["

if(strCommand=="

pre"

pageindex=pageindex-1;

pageindex=pageindex+1;

]=pageindex;

#endregion

privatestring_AuthorName;

protectedstringAuthorName

get{return_AuthorName;

set{_AuthorName=value;

protectedvoidhylArticleAuthor_Click(objectsender,EventArgse)

LinkButtonhylArticleAuthor=(LinkButton)sender;

if(hylArticleAuthor!

=null)

AuthorName=hylArticleAuthor.Text.ToString();

eSchool.JXKYW.Library.UserMappingsUserMapping=(frompinDataContext.UserMappings

wherep.LoginName.Equals(AuthorName)

if(UserMapping!

AnonymouEntityID=Convert.ToInt32(UserMapping.EntityID);

AnonymouEntityType="

Contact"

Response.Redirect("

~/PersonalDefault.aspx?

Type=3"

}

#endregion

#region这是前台代码

<

%@ControlLanguage="

C#"

AutoEventWireup="

true"

CodeBehind="

WUCGrid.ascx.cs"

Inherits="

Web.Collections.UserControl.WUCGrid"

%>

<

%@Registersrc="

../../Common/UserControl/ToolBar.ascx"

tagname="

ToolBar"

tagprefix="

uc1"

../../Common/UserControl/Pager.ascx"

Pager"

uc2"

../../Common/UserControl/SecondLevelMenu.ascx"

SecondLevelMenu"

uc3"

uc3:

SecondLevelMenuID="

SecondLevelMenu1"

runat="

server"

/>

asp:

LabelID="

Label1"

Text="

没变化"

>

/asp:

Label>

LinkButtonID="

lkPre"

CommandArgument="

OnCommand="

IndexChanging"

上一页<

LinkButton>

linkbuttonID="

lkNext"

next"

>

下一页<

linkbutton>

DataListID="

dl"

DataKeyField="

ondatabinding="

dl_DataBinding"

ondeletecommand="

dl_DeleteCommand"

ItemTemplate>

table>

tr>

td>

td>

收藏日期:

IDLabel"

Text='

%#Eval("

CreateTime"

"

{0:

yyyy-mm-dd}"

)%>

/td>

/tr>

lblCollName"

%#Eval("

CollectorName"

)%>

:

Remark"

标题:

lnkBtnTitle"

%#(Eval("

ArticleTitle"

)).ToString().Length>

25?

(Eval("

)).ToString().Substring(0,25):

Eval("

OnClick="

lnkBtnTitle_Click"

CommandArgument='

ArticleID"

tdstyle="

color:

Gray"

内容:

ArticleContent"

35?

)).ToString().Substring(0,35)+"

......"

来自:

hylArticleAuthor"

hylArticleAuthor_Click"

AuthorName"

tdalign="

right"

lnkBtnDelete"

CommandName="

Delete"

OnClientClick="

returnconfirm('

是否确认删除?

删除<

hr/>

/table>

/ItemTemplate>

DataList>

!

--如果没有数据就显示-->

PanelID="

&

nbsp;

divstyle="

font-family:

@华文楷体;

font-size:

xx-large;

lblNo"

噢~~~~NO~~~~您还没有收藏过文章,赶快去收藏吧~<

/div>

Panel>

一。

以下是分页功能:

#regionDataList分页

publicstaticDataSetGetDataSet(stringsql)//得到数据集

//得到当前登录名;

DataSetobjds=GetDataSet(sql);

//得到数据表;

数据集的第一个Table;

为默认数据源

//允许分页

/*CurrentPageIndex获取或设置当前页的索引。

用视图来保存pageindex;

没有视图时候给0;

在page_load事件中给值为0

{

if(!

{

ViewState["

BindData();

这里就执行一下分页函数

}

}*/

objPds.IsFirstPage)//IsFirstPage获取一个值,该值指示当前页是否是首页。

0)//DataSourceCount获取数据源中的项数。

//将datalist的数据源设置为pagedatasourse

//关键值

//然后最后在讲datalist绑定一下;

//这里很重要;

要再一次执行分页函数;

二。

查找数据库中某张表中的某条数据是否存在

#region

#endregion

三。

弹框问题;

ScriptManager.RegisterStartupScript(this.Page,this.Page.GetType(),System.DateTime.Now.Ticks.ToString(),

"

script>

alert('

请先登录!

)<

/script>

false);

四。

点击收藏按钮时候弹出一个文本框;

并且带有输入文本框;

所使用ajax控件;

前台代码:

#region

<

CollectionPnl"

Visible="

false"

collectionLHyBtn"

加入收藏"

onclick="

collectionLBtn_Click"

ButtonID="

CollectionBtn"

CausesValidation="

Style="

display:

none"

ajax:

ModalPopupExtenderID="

ModalPopupExtender"

BackgroundCssClass="

modalBackground"

Drag="

PopupDragHandleContro

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1