Geeks With Blogs

News


Rodney Vinyard - .NET & SQL Developer When all is said and done, more will be said than done
Bubble Web User Control Event to Parent Web Page
 
///////////////////////////////////////////////////////////////////
//User Control
///////////////////////////////////////////////////////////////////
 
public partial class UserControls_ListRequests : System.Web.UI.UserControl
{
    // Delegate declaration
    public delegate void GridSelectHandler(int requestId);
 
    // Event declaration
    public event GridSelectHandler GridSelectEvent;
 
    protected void gvRequests_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridViewRow row = gvRequests.SelectedRow;
 
        int reqId = int.Parse(row.Cells[8].Text);
        OnGridSelectEvent(reqId);
    }
   protected virtual void OnGridSelectEvent(int requestId)
    {
        if (GridSelectEvent != null)
        {
            GridSelectEvent(requestId);
        }
    }
}
 
///////////////////////////////////////////////////////////////////
//Parent Page
///////////////////////////////////////////////////////////////////
public partial class ParentPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            this.ListRequests1.GridSelectEvent += new UserControls_ListRequests.GridSelectHandler(ListRequests1_GridSelectHandler);
        }
        catch (Exception ex)
        {
            lblErr.Text = ex.ToString();
        }
    }
    void ListRequests1_GridSelectHandler(int requestId)
      {
          System.Diagnostics.Debug.Write(requestId.ToString());
      }
}
Posted on Wednesday, January 19, 2011 10:39 AM Delegates and Events | Back to top


Comments on this post: Bubble Web User Control Event to Parent Web Page

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Rodney Vinyard | Powered by: GeeksWithBlogs.net