?
Solved

System.Web.UI.WebControls.CommandEventHandler(LinkButton_Command)

Posted on 2006-07-19
5
Medium Priority
?
656 Views
Last Modified: 2008-01-09
ASP.NET , C#
I have the following event handler set in a LinkButton control, which I placed into Page_Load.
I want to use the CommandEventHandler(LinkButton_Command) value after PostBack back in
Page_Load to filter a query, which eventually updates the same lbtn property. Needless to say,
I can't seem to be able to get the  CommandEventHandler(LinkButton_Command) value back into Page_Load.
                   
lbtn.CommandArgument = i.ToString();
                   
lbtn.Command += new System.Web.UI.WebControls.CommandEventHandler(LinkButton_Command);
0
Comment
Question by:JoeUS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17141569
>>I can't seem to be able to get the  CommandEventHandler(LinkButton_Command) value back into Page_Load.
That doesn't make any sense.  The value of what?

Bob
0
 

Author Comment

by:JoeUS
ID: 17141776

CommandEventHandler(LinkButton_Command)
calls the following method      
protected void LinkButton_Command(Object sender, CommandEventArgs e)
and in this method
e.CommandArgument holds the value of  lbtn.CommandArgument = i.ToString()

now here I make a
public string lbtnValue = e.CommandArgument;
but get nothing in lbtnValue in Load_page

I hope it helps
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1500 total points
ID: 17141966
This is the order of things:

1) Click on a LinkButton control
2) An post-back occurs
3) The Page_Load event is fire
4) The LinkButton_Command event is handled

As you can see, you can't get the value from Page_Load, because it hasn't happened yet.

Bob
0
 

Author Comment

by:JoeUS
ID: 17149381
so,
what is your suggestion to solve this problem.
I tried to set the value into a session var, label, text in the method they don't show up in Page_Load only after the second post-back.
Generally, how do get the LinkButton_Command event value back in one trip if I dynamically create a control and place it into Page_Load?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17160370
Can you describe the bigger picture and what you need to accomplish, so that I could recommend the "best" course of action, please?

Bob
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question