DataList控件的分页 [英] Pagination on DataList control
问题描述
标题说我的目标是在我的datalist控件上实现分页。
这是我从中获取数据的函数。
As the title says my aim is to implement pagination on my datalist control.
Here is my function from which im fetching the data.
public void LinkButton_Click(object sender, EventArgs e)
{
DrugDescriptionList.DataSource = null;
DrugDescriptionList.DataBind();
LinkButton l = (LinkButton)sender;
string FirstLetter = l.Text;
IBAL objbal = BALFactory.UIFactoryBAL.retrieveDrugNamesObject();
pg.DataSource = objbal.retrieveDrugNames(FirstLetter).DefaultView;
pg.AllowPaging = true;
pg.PageSize = 2;
pg.CurrentPageIndex = CurrentPage;
lnkbtnNext.Enabled = !pg.IsLastPage;
lnkbtnPrevious.Enabled = !pg.IsFirstPage;
DrugNameList.DataSource = pg;
DrugNameList.DataBind();
doPaging();
}
这是另一组EventHandlers,我应该称之为 LinkButton_Click(如上所示)
Here is another set of EventHandlers from which im supposed to call the "LinkButton_Click" (above shown)
protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName.Equals("lnkbtnPaging"))
{
CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
//Here i have to call the Binding function
}
}
protected void lnkbtnPrevious_Click(object sender, EventArgs e)
{
CurrentPage -= 1;
//Here i have to call the binding function
}
protected void lnkbtnNext_Click(object sender, EventArgs e)
{
CurrentPage += 1;
//Here i have to call the binding function
}
我尝试了很多方法,但是因为参数(对象发送者和EventArgs e)而得到错误
请帮我解释一下调用该功能。非常感谢:D
在我的情况下它的不同因为我使用了一个对象SENDER我必须在调用时将sender从.aspx转换为Linkbutton类型它在其他地方,我不知道如何
LinkButton l =(LinkButton)sender; < ---我在这行中出错了
我的问题是从另一个事件处理程序调用事件处理函数时要传递的参数吗?
I have tried many methods but im getting error bacause of the arguments(object sender and EventArgs e)
Please help me out on how to call that function. Thanks a lot :D
In my case its different becz i have used an object SENDER I would have to convert the "sender" from .aspx to Linkbutton type while calling it elsewhere, which i dont no how to
LinkButton l = (LinkButton)sender; <--- I get an error in this line
My Question is- wat are the arguments to be passed while calling a event handler function from another event handler ?
推荐答案
通过以下给出的解决方案链接。
[ ^ ]
Go through the below given link for your solution.
[^]
这篇关于DataList控件的分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!