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
166
Programatic databinding with manual CRUD handling
posted

Can you please tell me if programatic databinding with manual CRUD handling is even possible with the WebDataGrid? I can honestly say I have never in my 15 years as a software developer come across a comercial product that had so many bugs in it or contained such poor functionality and event handling as this control. The only part of the editing core that seems to be handled accurately is the RowAdding behaviour. Every time I turn a corner I am faced with another bug and it is driving me crazy!

Even though I have turned all ViewState handling on the control off, it still seems to be caching data on the client even after a rebind. The delete I have coded on the ItemCommand event deletes the correct item from the database but after rebinding the refreshed data source, the client seems to rebind the previously requested datasource and for some reason drops the last record off and the one I deleted is still visible even though its not part of the new datasource. After a full refresh (Ctrl+F5)  of the page this is immediatley evident.

As for the RowUpdating event, it doesn't get fired until another completely separate control on the page causes a full postback even though the RowUpdated event (which doesn't contain the row values) fires as soon as the selected row is changed. Is this a joke?! Please explain to me the rationalle  behind this because I am baffled by it.

Next, if I try and add an AjaxControlToolkit ConfirmButtonExtender to a template column I get an error telling me that I have duplicate control id's after a postback.

These are obviously known problems as there are numerous posts about all the issues I have come across on this forum for which you fail to provide a valid solution. Can these problems be resolved or should I just get my money back?

-------------------------------------------------------------------------------------------------------------------------------------
Markup :
-------------------------------------------------------------------------------------------------------------------------------------

 <asp:ScriptManager runat="server"></asp:ScriptManager>
       
    <span class="TitleText">TEST TEST TEST</span><br /><br />

    <ig:WebDataGrid ID="grdClients" runat="server" EnableViewState="false" EnableAjaxViewState="false" EnableDataViewState="false" DataKeyFields="ClientId" StyleSetName="Office2007Black" Height="375px" Width="100%" AutoGenerateColumns="False"
        OnRowAdding="grdClients_RowAdding"
        OnRowUpdating="grdClients_RowUpdating"
        OnItemCommand="grdClients_ItemCommand">
        <Columns>
            <ig:BoundDataField DataFieldName="ClientName" Key="ClientName">
                <Header Text="Client"></Header>
            </ig:BoundDataField>
            <ig:TemplateDataField Key="Delete" Width="20px">
                <ItemTemplate>
                    <asp:ImageButton ID="btnDelete" runat="server" CommandArgument='<%# Eval("ClientId") %>' AlternateText="Delete" ImageUrl="~/images/btn_close2.png" />
                </ItemTemplate>
            </ig:TemplateDataField>
        </Columns>
        <Behaviors>
            <ig:Activation Enabled="true" />
            <ig:Sorting Enabled="true" />
            <ig:ColumnResizing Enabled="true" />
            <ig:EditingCore AutoCRUD="false" >
                <Behaviors>
                    <ig:RowAdding>
                        <EditModeActions MouseClick="Double" />
                    </ig:RowAdding>
                    <ig:CellEditing>
                        <CellEditingClientEvents ExitedEditMode="grdClients_ExitedEditMode"/>
                        <EditModeActions MouseClick="Double" />
                    </ig:CellEditing>
                </Behaviors>
            </ig:EditingCore>
        </Behaviors>
    </ig:WebDataGrid>

-------------------------------------------------------------------------------------------------------------------------------------
Codebehind :
-------------------------------------------------------------------------------------------------------------------------------------

 protected void Page_Load(object sender, EventArgs e)
        {
            this.InitialisePage(!Page.IsPostBack);
        }

        public void InitialisePage(bool refresh)
        {
            if (refresh)
            {
                MPE.dOOdads.PayloadData.Clients clients = new MPE.dOOdads.PayloadData.Clients(HttpContext.Current.Server.MachineName, Common.Tools.GetApplicationDataBase());

                clients.LoadAll();

                this.grdClients.DataSource = clients.DefaultView.Table;
                this.grdClients.DataBind();

                this.ViewState.Add("grdClients.DataSource", clients.DefaultView.Table);
            }
            else
            {
                this.grdClients.DataSource = this.ViewState["grdClients.DataSource"];
            }
        }

        protected void grdClients_ItemCommand(object sender, Infragistics.Web.UI.GridControls.HandleCommandEventArgs e)
        {
            try
            {
                MPE.dOOdads.PayloadData.Clients clients = new MPE.dOOdads.PayloadData.Clients(HttpContext.Current.Server.MachineName, Common.Tools.GetApplicationDataBase());

                clients.LoadByPrimaryKey(int.Parse(e.CommandArgument.ToString()));
                clients.DeleteAll();
                clients.Save();

                this.InitialisePage(true);
            }
            catch
            {
                MPE.Common.Tools.MessageBox(this.Page, "Client is in use and cannot be deleted.");
            }
        }

        protected void grdClients_RowAdding(object sender, Infragistics.Web.UI.GridControls.RowAddingEventArgs e)
        {
            MPE.dOOdads.PayloadData.Clients clients = new MPE.dOOdads.PayloadData.Clients(HttpContext.Current.Server.MachineName, Common.Tools.GetApplicationDataBase());

            clients.AddNew();
            clients.UserClientId = Common.Session.GetUserAccount().ClientId;
            clients.ClientName = e.Values["ClientName"].ToString();
            clients.Save();

            this.InitialisePage(true);
        }

        protected void grdClients_RowUpdating(object sender, Infragistics.Web.UI.GridControls.RowUpdatingEventArgs e)
        {
            MPE.dOOdads.PayloadData.Clients clients = new MPE.dOOdads.PayloadData.Clients(HttpContext.Current.Server.MachineName, Common.Tools.GetApplicationDataBase());

            clients.LoadByPrimaryKey((int)((object[])e.RowID["key"])[0]);
            clients.ClientName = e.Values["ClientName"].ToString();
            clients.Save();

            this.InitialisePage(true);
        }

 

Parents
No Data
Reply
  • 12025
    posted

    Hello Steve, 

    I apologize for the inconvenience you are having while using the product. The behavior you are experiencing doesn't sound right like the updating event not firing, while the updated event gets fired everytime you switch a row. Also, the viewstate disabled should not render any grid viewstate. There is also a 'dataviewstate' property, that holds the data. You may want to try out disabling that as well. 

    I would like to let you know that the support team are looking deeper into the issues, and will soon get in touch with you to provide proper resolution. 

    I request your patience while we try and help you out. You can also direct any other product concerns or suggestions directly to me at : murtazaa@infragistics.com

    Best Regards, 

    Taz. 

Children