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
215
ItemCommand not firing
posted

Hi

I'am working with infragistics webdatagrid (Version: 15.1.20151.1018).  This component is used in a master page.

I create dynamicaly the grid (the grid is put in a webTab) in witch a put a image button. So when the end user is clicked in the button a should open a new page but the event doesn't fired.

Is there a work a round for this problem?

Thank's

Christophe

//Create the gridView when fill the Tab

        private void FillTab(Infragistics.Web.UI.LayoutControls.ContentTabItem tab, int index)

        {

//Select the data via Linq

                var ResuStdOper = (from s in db.vRESU_STD_OPERs

                                   where s.NOM_LIGNE.Equals("AC02")

                                   select s).ToList();

 

 

 

                WebDataGrid GV = new WebDataGrid();

                GV.ID = "GV" + index.ToString();

                GV.AutoGenerateColumns = false;

                GV.DataKeyFields = "ID_RESULTAT";

                GV.EnableAjax = false;

                GV.EnableDataViewState = true;

                GV.EnableViewState = true;               

                GV.ItemCommand += new ItemCommandEventHandler(WebDataGrid1_ItemCommand);

                Selection gridSelection = GV.Behaviors.CreateBehavior<Selection>();

                gridSelection.CellClickAction = CellClickAction.Row;

                gridSelection.RowSelectType = SelectType.Single;

 

                RowSelectors gridselectorw = GV.Behaviors.CreateBehavior<RowSelectors>();

                gridselectorw.Enabled = true;

 

                Selection selectionBehavior = GV.Behaviors.Selection;

                if (selectionBehavior == null)

                {

                    // Create the behavior

                    Selection selection = new Selection();

 

                    // Add to behaviors collection

                    GV.Behaviors.Add(selection);

                    

                    // Set its options

                    selection.CellClickAction = CellClickAction.Row;

                    selection.RowSelectType = SelectType.Single;

                   

                }

                RowSelectors gridselectorbehavior = GV.Behaviors.RowSelectors;

                if (gridselectorbehavior==null)

                {

 

                }

                //Add the

                TemplateDataField templateField1 = new TemplateDataField(true);

                templateField1.Key = "TemplateField1";

                templateField1.Header.Text = "Template Column";

                GV.Columns.Add(templateField1);

               

                TemplateDataField templateColumn1 = (TemplateDataField)GV.Columns["TemplateField1"];

 

                templateColumn1.ItemTemplate = new CustomItemTemplate();

               

               

 

                var col1 = new BoundDataField { Key = "NOM_STANDARD" };

                col1.Header.Text = "Nom standard";

                col1.Width = 100;

                var col2 = new BoundDataField { Key = "NOM_OPERATEUR" };

                col2.Header.Text = "Nom opérateur";

                col2.Width = 75;

                GV.Columns.Add(col1);

                GV.Columns.Add(col2);

                GV.DataSource = ResuStdOper;

                GV.DataBind();

                tab.Controls.Add(GV); //Add the grid to the tab

                GV.EnsureTemplates();

}

//???? Why is this event not fired????

        protected void WebDataGrid1_ItemCommand(object sender, HandleCommandEventArgs e)

        {

            string IdResu = e.CommandArgument.ToString();

        }

//The class used for create the button

public  class CustomItemTemplate : ITemplate

    {

        #region ITemplate Members

        public void InstantiateIn(Control container)

        {

            ImageButton imgBtn = new ImageButton();

            imgBtn.ID = "ImageButton1";

            imgBtn.ImageUrl = "images/edit.png";

            imgBtn.Width=System.Web.UI.WebControls.Unit.Pixel(32);

            imgBtn.Height = System.Web.UI.WebControls.Unit.Pixel(32);

            imgBtn.CommandName = "security";

            imgBtn.CommandArgument = DataBinder.Eval((((Infragistics.Web.UI.TemplateContainer)container).DataItem), "ID_RESULTAT").ToString();

                

            imgBtn.ToolTip = "Manage Security";

            container.Controls.Add(imgBtn);

        }

        #endregion

    }

App_Data.ADHERENCE_CILDataContext db = new App_Data.ADHERENCE_CILDataContext();                var ResuStdOper = (from s in db.vRESU_STD_OPERs                                   where s.NOM_LIGNE.Equals("AC02")                                   select s).ToList();
                //GV.AutoGenerateColumns = false;                //GV.RowStyle.BackColor = Color.Blue;                //GV.RowStyle.BorderColor = Color.Black;                //GV.RowStyle.BorderWidth = 1;                //GV.DataKeyNames = "id_resultat";
                //BoundField bf = new BoundField();                //bf.HeaderText = "Nom standard";                //bf.DataField = "NOM_STANDARD";                //GV.Columns.Add(bf);
                //BoundField bf1 = new BoundField();                //bf1.HeaderText = "Nom opérateur";                //bf1.DataField = "NOM_OPERATEUR";                //GV.Columns.Add(bf1);
 
                WebDataGrid GV = new WebDataGrid();                GV.ID = "GV" + index.ToString();                GV.AutoGenerateColumns = false;                GV.DataKeyFields = "ID_RESULTAT";                GV.EnableAjax = false;                GV.EnableDataViewState = true;                GV.EnableViewState = true;                                GV.ItemCommand += new ItemCommandEventHandler(WebDataGrid1_ItemCommand);            https://es.infragistics.com/community/forums/t/93050.aspx                Selection gridSelection = GV.Behaviors.CreateBehavior<Selection>();                gridSelection.CellClickAction = CellClickAction.Row;                gridSelection.RowSelectType = SelectType.Single;
                RowSelectors gridselectorw = GV.Behaviors.CreateBehavior<RowSelectors>();                gridselectorw.Enabled = true;                // To get reference to a behavior, use its property of the same name                //http://help.infragistics.com/Help/Doc/ASPNET/2011.2/CLR4.0/html/WebDataGrid_Adding_a_Behavior_at_Runtime.html                Selection selectionBehavior = GV.Behaviors.Selection;                if (selectionBehavior == null)                {                    // Create the behavior                    Selection selection = new Selection();
                    // Add to behaviors collection                    GV.Behaviors.Add(selection);                                        // Set its options                    selection.CellClickAction = CellClickAction.Row;                    selection.RowSelectType = SelectType.Single;                                    }                RowSelectors gridselectorbehavior = GV.Behaviors.RowSelectors;                if (gridselectorbehavior==null)                {
                }                //ImageButton imgBtn = new ImageButton();                //imgBtn.ID = "ImageButton1";                //imgBtn.ImageUrl = "images/edit.png";                //imgBtn.CommandName = "security";                //imgBtn.CommandArgument = ((DataRowView)((TemplateContainer)container).DataItem)["ID_CATEGORIE"].ToString();                //imgBtn.ToolTip = "Manage Security";                //container.Controls.Add(imgBtn);                TemplateDataField templateField1 = new TemplateDataField(true);                templateField1.Key = "TemplateField1";                templateField1.Header.Text = "Template Column";                GV.Columns.Add(templateField1);                                TemplateDataField templateColumn1 = (TemplateDataField)GV.Columns["TemplateField1"];
                templateColumn1.ItemTemplate = new CustomItemTemplate();                                
                var col1 = new BoundDataField { Key = "NOM_STANDARD" };                col1.Header.Text = "Nom standard";                col1.Width = 100;                var col2 = new BoundDataField { Key = "NOM_OPERATEUR" };                col2.Header.Text = "Nom opérateur";                col2.Width = 75;                GV.Columns.Add(col1);                GV.Columns.Add(col2);                GV.DataSource = ResuStdOper;                GV.DataBind();                tab.Controls.Add(GV);                GV.EnsureTemplates();

  • 7555
    Offline posted

    Hello Strich,

    I followed the code you have provided and was unable to reproduce the behavior you're describing.

    I have created a sample of WebdataGrid. In the sample I added a master page and added a WebDatagrid in a webTab control.I added an ImageButton as a template data field in the grid
    And now when I clicked the image button, WebDataGrid1_ItemCommand event does fired.

    I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.

    Please note as the provided code has lots of dependent code I was not able to include it into my sample. I would recommend you to isolate the code and debug it to find the cause of the issue.

    It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing. This can be done by either making the sample that I provided more like your application or by isolating the behavior from your application by removing dependencies on any third parties or databases.

    Please let me know if I can provide any further assistance.

    WebdataGridWebTab.zip
  • 7555
    Offline posted

    Hello Strich, 

    Thank you for posting to our forum. 

    I would like to update you that currently I am putting together all the code you have provided, in order to have a working sample and able to reproduce the same scenario at my end. 

    I will provide you an update by tomorrow EOD .