wire up in events for C# newbie

Discussion in 'ASP .Net' started by jhcorey@yahoo.com, Aug 10, 2005.

  1. Guest

    I mentioned this recently in another post.

    Let's say I want to use the ItemDataBound event for a datagrid.

    I assume that I need:
    this.DataGrid1.ItemDataBound += new
    System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound);

    in the InitializeComponent function. Is this correct, or is there
    another way
    to do this?

    Because (1) the comments say not to touch this; and (2) this function
    keeps getting cleared out, which I've noticed is a known problem.
    I'm evidently carrying some habits over from vb.net that keep messing
    me up.

    TIA,
    Jim
     
    , Aug 10, 2005
    #1
    1. Advertising

  2. In Design View of your page, select the object you want to wire up events for
    and open the Properties tab. On this tab you should see a lightning bolt.
    Click the bolt and in here you can see all of the available events for your
    selected object.

    HTH
    --
    Ian


    "" wrote:

    > I mentioned this recently in another post.
    >
    > Let's say I want to use the ItemDataBound event for a datagrid.
    >
    > I assume that I need:
    > this.DataGrid1.ItemDataBound += new
    > System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound);
    >
    > in the InitializeComponent function. Is this correct, or is there
    > another way
    > to do this?
    >
    > Because (1) the comments say not to touch this; and (2) this function
    > keeps getting cleared out, which I've noticed is a known problem.
    > I'm evidently carrying some habits over from vb.net that keep messing
    > me up.
    >
    > TIA,
    > Jim
    >
    >
     
    =?Utf-8?B?RU5JWklO?= .enizin.net>, Aug 10, 2005
    #2
    1. Advertising

  3. Jim,

    You can set the event handler in .aspx file as an attribute:

    <asp:datagrid ... OnItemDataBound="DataGrid1_ItemDataBound" .. >

    This format doesn't use the Design view and it doesn't get cleared out. You
    will need to declare DataGrid1_ItemDataBound as protected.

    Eliyahu

    <> wrote in message
    news:...
    > I mentioned this recently in another post.
    >
    > Let's say I want to use the ItemDataBound event for a datagrid.
    >
    > I assume that I need:
    > this.DataGrid1.ItemDataBound += new
    >

    System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBo
    und);
    >
    > in the InitializeComponent function. Is this correct, or is there
    > another way
    > to do this?
    >
    > Because (1) the comments say not to touch this; and (2) this function
    > keeps getting cleared out, which I've noticed is a known problem.
    > I'm evidently carrying some habits over from vb.net that keep messing
    > me up.
    >
    > TIA,
    > Jim
    >
     
    Eliyahu Goldin, Aug 11, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Newby
    Replies:
    1
    Views:
    618
    =?Utf-8?B?c2FyYQ==?=
    Feb 28, 2005
  2. Replies:
    2
    Views:
    405
    Jonathan
    Apr 5, 2007
  3. David
    Replies:
    5
    Views:
    286
    Jeffrey Tan[MSFT]
    Feb 18, 2004
  4. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    407
    Chris
    Aug 30, 2005
  5. Dan
    Replies:
    5
    Views:
    132
Loading...

Share This Page