Professional Web Applications Themes

eventhandler of a programmatically created datagird - ASP.NET Data Grid Control

Hello, I have a programmatically created datagrid (no def in the aspx-file) dg2.DataBind(); holder.Controls.Add(dg2); // placeholder in the method InitializeComponent i want to add events (sorting paging) etc. to this Datagrid dg2: private void InitializeComponent() { this.dg2.SortCommand += new System.Web.UI.WebControls.DataGridSortCommandEvent Handler(this.dg_Sort); ....} but unfortunately it doesn't work..nothings happens? or sometimes VS deletes this line Any idea? thank you as...

  1. #1

    Default eventhandler of a programmatically created datagird

    Hello,

    I have a programmatically created datagrid (no def in the aspx-file)


    dg2.DataBind();
    holder.Controls.Add(dg2); // placeholder


    in the method InitializeComponent i want to add events (sorting paging) etc.
    to this Datagrid dg2:

    private void InitializeComponent()
    {
    this.dg2.SortCommand += new
    System.Web.UI.WebControls.DataGridSortCommandEvent Handler(this.dg_Sort);
    ....}

    but unfortunately it doesn't work..nothings happens? or sometimes VS deletes
    this line

    Any idea?

    thank you

    as





    Anna Schmidt Guest

  2. #2

    Default Re: eventhandler of a programmatically created datagird

    Anna,

    I already had that problem in the past, where indeed, VS removes the line
    from the initializecomponent method.
    An easy workaround is to call a method that initialize the events from
    within the page_load method, and in that case, it is no longer removed by
    VS.
    EX:
    void Page_Load(){
    HookEventsOnControls();
    }
    private void HookEventsOnControls(){
    this.dg2.SortCommand += new
    System.Web.UI.WebControls.DataGridSortCommandEvent Handler(this.dg_Sort);
    }
    "Anna Schmidt" <whygohomegmx.net> wrote in message
    news:c21p1a$1naeu2$1ID-92243.news.uni-berlin.de...
    > Hello,
    >
    > I have a programmatically created datagrid (no def in the aspx-file)
    >
    >
    > dg2.DataBind();
    > holder.Controls.Add(dg2); // placeholder
    >
    >
    > in the method InitializeComponent i want to add events (sorting paging)
    etc.
    > to this Datagrid dg2:
    >
    > private void InitializeComponent()
    > {
    > this.dg2.SortCommand += new
    > System.Web.UI.WebControls.DataGridSortCommandEvent Handler(this.dg_Sort);
    > ...}
    >
    > but unfortunately it doesn't work..nothings happens? or sometimes VS
    deletes
    > this line
    >
    > Any idea?
    >
    > thank you
    >
    > as
    >
    >
    >
    >
    >

    SB Guest

Similar Threads

  1. Programmatically created stamps with IAC
    By Metal_Detector@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 1
    Last Post: November 16th, 04:08 AM
  2. Maintaining state in programmatically created composite user controls
    By mark.norgate@gmail.com in forum ASP.NET Building Controls
    Replies: 3
    Last Post: March 23rd, 11:20 AM
  3. eVENThANDLER PROBLEM
    By J McD in forum ASP.NET Building Controls
    Replies: 1
    Last Post: February 23rd, 10:13 AM
  4. Replies: 0
    Last Post: September 10th, 08:48 AM
  5. Programmatically created web user control events
    By Jonas in forum ASP.NET Building Controls
    Replies: 1
    Last Post: August 27th, 08:17 PM

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