Pager and Event Handling

Ask a Question related to ASP.NET General, Design and Development.

  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. Similar Questions and Discussions

    1. Event Handling of pages
      I want to display pages that are not connected to the application. The application is to activate a page then allow for a return. If I put the pages...
    2. Event Handling
      I am having a difficult time with hadling events within my composite control. Sometimes what I do works perfectly, other times capturing an event is...
    3. EditCommandColumn event handling
      I am creating a datagrid programmatically and am trying to add an EditCommandColumn to the datagrid but I'm having a hard time getting events for...
    4. ASP.NET Event handling.
      Hi Friends I am having problem in Event handling in ASP.NET. Let me tell you what I am doing, I have having DataGrid for which I am using...
    5. ASP Event Handling
      Hi I want to handle events of the AO Connection object in my ASP page. How can I do it? Please help me out. Thanks - Anuj
  3. #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@yahoo.com> wrote in message
    news:uT9TOmWTDHA.2280@TK2MSFTNGP12.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

  4. #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" <chrisj@mvps.org> wrote in message
    news:OxviFwWTDHA.2180@TK2MSFTNGP10.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@yahoo.com> wrote in message
    > news:uT9TOmWTDHA.2280@TK2MSFTNGP12.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

Posting Permissions

  • You may not post new threads
  • You may 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