Professional Web Applications Themes

Pager and Event Handling - ASP.NET General

OnItemCreated method of DataGrid I modified the Pager cell to have a button TableCell pager = (TableCell)e.Item.Controls[0]; ImageButton hImg = new ImageButton(); hImg.ImageAlign=ImageAlign.Left; hImg.ImageUrl="some.gif"; hImg.CommandName="SomeCommand"; pager.Controls.AddAt(0,hImg); When i click on the ImageButton I get: Object reference not set to an instance of an object How can i handle the event from this Button. Appreciate any help. Thanks...

  1. #1

    Default Pager and Event Handling

    OnItemCreated method of DataGrid I modified the Pager cell to have a button

    TableCell pager = (TableCell)e.Item.Controls[0];
    ImageButton hImg = new ImageButton();
    hImg.ImageAlign=ImageAlign.Left;
    hImg.ImageUrl="some.gif";
    hImg.CommandName="SomeCommand";
    pager.Controls.AddAt(0,hImg);

    When i click on the ImageButton I get:
    Object reference not set to an instance of an object
    How can i handle the event from this Button.
    Appreciate any help. Thanks








    sunil Guest

  2. #2

    Default Re: Pager and Event Handling

    What are you doing in your onclick method? It appears as if the issue is in
    the handler, not in the creation.

    --
    Chris Jackson
    Software Engineer
    Microsoft MVP - Windows XP
    Windows XP Associate Expert
    --
    "sunil" <sunil_godiyal> wrote in message
    news:uT9TOmWTDHA.2280TK2MSFTNGP12.phx.gbl...
    > OnItemCreated method of DataGrid I modified the Pager cell to have a
    button
    >
    > TableCell pager = (TableCell)e.Item.Controls[0];
    > ImageButton hImg = new ImageButton();
    > hImg.ImageAlign=ImageAlign.Left;
    > hImg.ImageUrl="some.gif";
    > hImg.CommandName="SomeCommand";
    > pager.Controls.AddAt(0,hImg);
    >
    > When i click on the ImageButton I get:
    > Object reference not set to an instance of an object
    > How can i handle the event from this Button.
    > Appreciate any help. Thanks
    >
    >
    >
    >
    >
    >
    >
    >

    Chris Jackson Guest

  3. #3

    Default Re: Pager and Event Handling

    Thanks Chris!!.Appreciate your reply
    The ImageButton is not part of the aspx page. It is created dynamically and
    added to the pager row.
    How do i write onclick handler for it.?
    i tried something like this.

    hImg.Attributes["onclick"]="javascript:__doPostBack('"+DataGrid1.ClientID +"'
    ,'');";
    but my OnItemCommand handler of datagrid is not called.



    "Chris Jackson" <chrisjmvps.org> wrote in message
    news:OxviFwWTDHA.2180TK2MSFTNGP10.phx.gbl...
    > What are you doing in your onclick method? It appears as if the issue is
    in
    > the handler, not in the creation.
    >
    > --
    > Chris Jackson
    > Software Engineer
    > Microsoft MVP - Windows XP
    > Windows XP Associate Expert
    > --
    > "sunil" <sunil_godiyal> wrote in message
    > news:uT9TOmWTDHA.2280TK2MSFTNGP12.phx.gbl...
    > > OnItemCreated method of DataGrid I modified the Pager cell to have a
    > button
    > >
    > > TableCell pager = (TableCell)e.Item.Controls[0];
    > > ImageButton hImg = new ImageButton();
    > > hImg.ImageAlign=ImageAlign.Left;
    > > hImg.ImageUrl="some.gif";
    > > hImg.CommandName="SomeCommand";
    > > pager.Controls.AddAt(0,hImg);
    > >
    > > When i click on the ImageButton I get:
    > > Object reference not set to an instance of an object
    > > How can i handle the event from this Button.
    > > Appreciate any help. Thanks
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    >
    >

    sunil Guest

Similar Threads

  1. Event Handling of pages
    By jlopes151 in forum Macromedia Flex General Discussion
    Replies: 1
    Last Post: April 30th, 07:25 PM
  2. Event Handling
    By John Bankhead in forum ASP.NET Building Controls
    Replies: 0
    Last Post: June 24th, 05:48 PM
  3. EditCommandColumn event handling
    By tantilis@gmail.com in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: April 22nd, 02:53 PM
  4. ASP.NET Event handling.
    By Makarand in forum ASP.NET General
    Replies: 0
    Last Post: July 24th, 01:46 PM
  5. ASP Event Handling
    By Anuj in forum ASP Components
    Replies: 2
    Last Post: July 18th, 08:17 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139