Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
175
Creating a WebDataMenu programmatically in server side code behind
posted

Can someone provide sample code in which a WebDataMenu is coded completely on the server-side?  By completely, I mean that server side code creates the WebDataMenu and makes all modifications to it, and there are no <WebDataMenu> tags in the markup files that ship with our application.  We want to use a WebDataMenu in each cell of a column in a WebDataGrid.  Each of those instances of WebDataMenu needs to be created during the grid's OnInitializeRow event because each row's menu contents are dependent upon the data in the row and complex server side logic.  We were able to accomplish all of this with UltraWebMenu (which Infragistics retired after WebDataMenu was introduced), but we need an example of how to do it with WebDataMenu.

Parents
  • 2525
    posted

    Hi Michael,

    This behavior can be achieved by using a TemplatedDataField containing a WebDataMenu. Here is an example of the markup of a WebDataMenu within a WebDataGrid:

    <ig:TemplateDataField Key="WDM">
     <ItemTemplate>
      <ig:WebDataMenu runat="server" ID="WDM">
       <Items>
        <ig:DataMenuItem>
         <Template>
          <p>Item</p>
         </Template>
        </ig:DataMenuItem>
       </Items>
      </ig:WebDataMenu>
     </ItemTemplate>
    </ig:TemplateDataField>

    Within the Initialize Row event, we can obtain the control by using the FindControl method and using the control's ID we set in the markup. In this case, the WebDataMenu's ID is WDM. Here's an example of the code behind:

    protected void WDG1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
    {
     Control control = e.Row.Items[2].FindControl("WDM");
    }

    I am attaching a sample I used to test this behavior.

    Also, can you provide more details on what you are looking to achieve with the WebDataMenu within the WebDataGrid.

    Let me know if I can be of further assistance.

    WDMtemplatedWDG.zip
Reply Children
No Data