Click here to Skip to main content
15,905,414 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void Page_Load(object sender, EventArgs e)
  {

      if (!IsPostBack)
      {
          MultiView1.ActiveViewIndex = 0;
         gvUserInfo_ItemCommand(gvUserInfo,new ListViewCommandEventArgs());//error
         string str = "SELECT * FROM SetPayout_Master";
          com = new SqlCommand(str, con);
          com.CommandType = CommandType.Text;
          da = new SqlDataAdapter(com);
          DataTable dtstr = new DataTable();
          da.Fill(dtstr);
          if (dtstr.Rows.Count > 0)
          {
              viewSetPayout();

          }
      }
  }


//gvUserInfo is ListView
error:

No overload for method 'ListViewCommandEventArgs' takes '0' arguments
Posted
Updated 18-Feb-13 22:56pm
v2

That is an event handler - you do not normally call event handlers directly, they should be called through the events mechanism instead.

If you want to execute the same code in your event handler and your page load, then I would suggest that you extract the code to a separate method and call it from both locations. You then won't need to create the EventArgs, and your problem will disappear on it's own.
 
Share this answer
 
Comments
PipuMon 19-Feb-13 5:32am    
Ya.
The error "No overload for method 'ListViewCommandEventArgs' takes '0' arguments" clearly tell that ListViewCommandEventArgs class has no constructor which receive 0 argument. Means ListViewCommandEventArgs constructor has argument(s) which you should supply.
So you wrongly call new ListViewCommandEventArgs(). Please see the definition of ListViewCommandEventArgs object specially its constructor definition. I guess then you understand which parameter should pass with that constructor and solve the problem.

Again event handler directly call is not good practice. You can write reusable function and from various event handler you can call that with appropriate arguments.
 
Share this answer
 

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