Click here to Skip to main content
15,113,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
As the title says my aim is to implement pagination on my datalist control.

Here is my function from which im fetching the data.
C#
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();

   }


Here is another set of EventHandlers from which im supposed to call the "LinkButton_Click" (above shown)

C#
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
   }

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 ?
Posted
Updated 10-Jul-13 9:03am
v2
Comments
[no name] 8-Jul-13 15:48pm
   
I would suggest that you create a separate method to call from all 4 of your events that you can pass the string that you need to use for retrieveDrugNames.
Nikhil_kk 11-Jul-13 12:33pm
   
Thanks a lot for the answer. . .Yes tat was my last option, but was just curious to no if there was any way. I guess im left with only this now.

1 solution

Go through the below given link for your solution.

[^]
   
Comments
Nikhil_kk 10-Jul-13 13:59pm
   
Thanks for the reply, Yes this would have been very easy if it was just a function without any arguments(given in the link) but in my case it is a event handler(with arguments) which i have to call and not just a simple function.

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 ?

Thanks again.
Dheeraj_Gupta 11-Jul-13 0:44am
   
Can you explain why do you required to perform the link button object casting of sender.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900