?
Solved

How to call ASP.NET event from another event

Posted on 2012-08-20
5
Medium Priority
?
706 Views
Last Modified: 2012-08-23
Hello,

How can I call "GridView1_SelectedIndexChanging(object sender, System.Web.UI.WebControls.GridViewSelectEventArgs e)" from
"protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)"

Thank you!!!
0
Comment
Question by:Rad1
  • 3
  • 2
5 Comments
 
LVL 20

Expert Comment

by:informaniac
ID: 38313234
why would you want to do that?

Just write the code you want into a private method and call that method.

Won't this work for you?
0
 

Author Comment

by:Rad1
ID: 38313478
Can you please elaborate with example?

Thank you!
0
 
LVL 20

Accepted Solution

by:
informaniac earned 2000 total points
ID: 38314891
What I was trying to say is:
GridView1_SelectedIndexChanging(object sender, System.Web.UI.WebControls.GridViewSelectEventArgs e)
{
           Method1();
}

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
            Method1();
}

Open in new window

0
 

Author Comment

by:Rad1
ID: 38318689
How can I call this code from
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)


int i = 0;
            foreach (GridViewRow gr in GridView1.Rows)
            {
                CheckBox cb = (CheckBox)gr.Cells[1].FindControl("ChkBx1");
                if (cb.Checked == false)
                {

                    if (!IsPostBack)
                    {
                        GridView1.Columns[i].Visible = false;
                    }
                }
            }

Open in new window

0
 

Author Closing Comment

by:Rad1
ID: 38327227
Thank you!!!
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

850 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