Insert item not firing

3 posts, 1 answers
  1. CRISTINA
    CRISTINA avatar
    7 posts
    Member since:
    Jul 2010

    Posted 27 May 2015 Link to this post

    Hi, I'm using a Three Tier Architecture, and I am able to see the documents from my Oracle database. Anyway I'm having some trouble with the Insert option.

    The grid loads fine and show the table content, I can click Add a New entry but when I click Insert nothing happens.



    Here is my code so far:

    The DAL makes the call to the DB, assigning properties through the Business Object class (below)

     

    public List<DocsBO> InsertDocuments()
            {
                using (_connection)
                {
                    _connection.Open();
                    using (_command = new OracleCommand("INSERT INTO PROM_DOCS (DOCID, DOCTITLE, DOCDESCRIPTION, FILENAME, FILENAMESTARTPLAY," +
                        "TYPE, LASTEDIT, DOCVERSION, THUMBNAIL, STATUS, DISCLOSABLE, PRODUCTID, LAST_USER, LAST_EDIT, CATEGORYNAME)" +
                        "VALUES (:DOCID, :DOCTITLE, :DOCDESCRIPTION, :FILENAME, :FILENAMESTARTPLAY, :TYPE, :LASTEDIT, :DOCVERSION, :THUMBNAIL, :STATUS," +
                        ":DISCLOSABLE, :PRODUCTID, :LAST_USER, :LAST_EDIT, :CATEGORYNAME)", _connection))
                    {
     
                        List<DocsBO> InsDocs = new List<DocsBO>();
     
                        using (OracleDataReader _dataReader = _command.ExecuteReader())
                        {
                            while (_dataReader.Read())
                            {
                                InsDocs.Add(new DocsBO());
                                InsDocs[InsDocs.Count - 1].Id = Convert.ToInt32(_dataReader["DOCID"]);
                                InsDocs[InsDocs.Count - 1].Name = _dataReader["DOCTITLE"].ToString();
                                InsDocs[InsDocs.Count - 1].Description = _dataReader["DOCDESCRIPTION"].ToString();
                                InsDocs[InsDocs.Count - 1].FileName = _dataReader["FILENAME"].ToString();
                                InsDocs[InsDocs.Count - 1].FileNameStartPlay = _dataReader["FILENAMESTARTPLAY"].ToString();
                                InsDocs[InsDocs.Count - 1].Type = Convert.ToInt32(_dataReader["TYPE"]);
                                InsDocs[InsDocs.Count - 1].LastEdit = Convert.ToDateTime(_dataReader["LASTEDIT"]);
                                InsDocs[InsDocs.Count - 1].Version = _dataReader["DOCVERSION"].ToString();
                                InsDocs[InsDocs.Count - 1].Thumbnail = _dataReader["THUMBNAIL"].ToString();
                                InsDocs[InsDocs.Count - 1].Status = Convert.ToInt32(_dataReader["STATUS"]);
                                InsDocs[InsDocs.Count - 1].Disclosable = Convert.ToBoolean(_dataReader["DISCLOSABLE"]);
                                #region if DBNull PRODUCTID
                                if (_dataReader["PRODUCTID"] == DBNull.Value)
                                {
                                    InsDocs[InsDocs.Count - 1].ProductId = 0;
                                }
                                else
                                {
                                    InsDocs[InsDocs.Count - 1].ProductId = Convert.ToInt32(_dataReader["PRODUCTID"]);
                                }
                                #endregion
                                InsDocs[InsDocs.Count - 1].LastUser = _dataReader["LAST_USER"].ToString();
                                InsDocs[InsDocs.Count - 1].LastEdit2 = Convert.ToDateTime(_dataReader["LAST_EDIT"]);
                                InsDocs[InsDocs.Count - 1].CategoryName = _dataReader["CATEGORYNAME"].ToString();
                            }
                        }
                        return InsDocs;
                    }
                }
            }

     

    The BLL takes the returning list from the DAL

     

    public List<DocsBO> InsertDocs()
            {
                List<DocsBO> _newDocs;
     
                DocsDal NewDocs = new DocsDal();
     
                _newDocs = NewDocs.InsertDocuments();
     
                return _newDocs;
            }

     

    The Presentation Layer containing the RadGrid takes the list and populates itself

    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
            {
                RadGrid1.DataSource = _BLL.LoadDocs();
            }
     

     Here is my Grid

    <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" GroupPanelPosition="Top"
            AllowPaging="True" AllowSorting="True" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AutoGenerateColumns="False">
            <MasterTableView CommandItemDisplay="Top" PageSize="20">
                <ItemStyle CssClass="radGridRows" />
                <AlternatingItemStyle CssClass="radGridRows" />
                <Columns>
                    <telerik:GridBoundColumn DataField="Id" FilterControlAltText="Filter column column" HeaderText="Id" UniqueName="column">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter column1 column" HeaderText="Name" UniqueName="column1">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Description" FilterControlAltText="Filter column2 column" HeaderText="Description" UniqueName="column2">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FileName" FilterControlAltText="Filter column3 column" HeaderText="File Name" UniqueName="column3">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FileNameStartPlay" FilterControlAltText="Filter column4 column" HeaderText="FN Start Play" UniqueName="column4">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Type" FilterControlAltText="Filter column5 column" HeaderText="Type" UniqueName="column5">
                    </telerik:GridBoundColumn>
                    <telerik:GridDateTimeColumn DataField="LastEdit" FilterControlAltText="Filter column6 column" HeaderText="Last Edit" UniqueName="column6" PickerType="DateTimePicker">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridBoundColumn DataField="Version" FilterControlAltText="Filter column7 column" HeaderText="Version" UniqueName="column7">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Thumbnail" FilterControlAltText="Filter column8 column" HeaderText="Thumbnail" UniqueName="column8">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Status" FilterControlAltText="Filter column9 column" HeaderText="Status" UniqueName="column9">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn DataField="Disclosable" DataType="System.Boolean" DefaultInsertValue="false" FilterControlAltText="Filter column10 column" HeaderText="Disclosable" UniqueName="column10">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridBoundColumn DataField="ProductId" FilterControlAltText="Filter column11 column" HeaderText="Product Id" UniqueName="column11" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="LastUser" FilterControlAltText="Filter column12 column" HeaderText="Last User" UniqueName="column12">
                    </telerik:GridBoundColumn>
                    <telerik:GridDateTimeColumn DataField="LastEdit2" FilterControlAltText="Filter column13 column" HeaderText="Last Edit" UniqueName="column13" Visible="false" PickerType="DateTimePicker">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridBoundColumn DataField="CategoryName" FilterControlAltText="Filter column14 column" HeaderText="Category Name" UniqueName="column14" Visible="false">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>

     

     And My Business Object Properties class

     

    public class DocsBO
        {
            private int DocId;
     
            public int Id
            {
                get { return DocId; }
                set { DocId = value; }
            }
     
            private string DocName;
     
            public string Name
            {
                get { return DocName; }
                set { DocName = value; }
            }
     
            private string DocDesc;
     
            public string Description
            {
                get { return DocDesc; }
                set { DocDesc = value; }
            }
     
            private string DocFileName;
     
            public string FileName
            {
                get { return DocFileName; }
                set { DocFileName = value; }
            }
     
            private string DocFileNameStartPlay;
     
            public string FileNameStartPlay
            {
                get { return DocFileNameStartPlay; }
                set { DocFileNameStartPlay = value; }
            }
     
            private int DocType;
     
            public int Type
            {
                get { return DocType; }
                set { DocType = value; }
            }
     
            private DateTime DocLastEdit;
     
            public DateTime LastEdit
            {
                get { return DocLastEdit; }
                set { DocLastEdit = value; }
            }
     
            private string DocVersion;
     
            public string Version
            {
                get { return DocVersion; }
                set { DocVersion = value; }
            }
     
            private string DocThumbnail;
     
            public string Thumbnail
            {
                get { return DocThumbnail; }
                set { DocThumbnail = value; }
            }
     
            private int DocStatus;
     
            public int Status
            {
                get { return DocStatus; }
                set { DocStatus = value; }
            }
     
            private bool DocDisclosable;
     
            public bool Disclosable
            {
                get { return DocDisclosable; }
                set { DocDisclosable = value; }
            }
     
            private int DocProductId;
     
            public int ProductId
            {
                get { return DocProductId; }
                set { DocProductId = value; }
            }
     
            private string DocLastUser;
     
            public string LastUser
            {
                get { return DocLastUser; }
                set { DocLastUser = value; }
            }
     
            private DateTime DocLastEdit2;
     
            public DateTime LastEdit2
            {
                get { return DocLastEdit2; }
                set { DocLastEdit2 = value; }
            }
     
            private string DocCategoryName;
     
            public string CategoryName
            {
                get { return DocCategoryName; }
                set { DocCategoryName = value; }
            }
             
     
        }

     

     I also tried making a call in that way:

    public List<DocsBO> InsertDocuments()
    {
        List<DocsBO> InsertDocs = new List<DocsBO>();
     
        using (_connection)
        {
            _connection.Open();
            using (_command = new OracleCommand("INSERT INTO PROM_DOCS (DOCID, DOCTITLE, DOCDESCRIPTION, FILENAME, FILENAMESTARTPLAY," +
                "TYPE, LASTEDIT, DOCVERSION, THUMBNAIL, STATUS, DISCLOSABLE, PRODUCTID, LAST_USER, LAST_EDIT, CATEGORYNAME)" +
                "VALUES (:DOCID, :DOCTITLE, :DOCDESCRIPTION, :FILENAME, :FILENAMESTARTPLAY, :TYPE, :LASTEDIT, :DOCVERSION, :THUMBNAIL, :STATUS," +
                ":DISCLOSABLE, :PRODUCTID, :LAST_USER, :LAST_EDIT, :CATEGORYNAME)", _connection))
                InsertDocs.Add(new DocsBO());
            InsertDocs[InsertDocs.Count - 1].Id = Convert.ToInt32(_command.Parameters.Add(":DOCID"));
            InsertDocs[InsertDocs.Count - 1].Name = _command.Parameters.Add(":DOCTITLE").ToString();
            InsertDocs[InsertDocs.Count - 1].Description = _command.Parameters.Add(":DOCDESCRIPTION").ToString();
            InsertDocs[InsertDocs.Count - 1].FileName = _command.Parameters.Add(":FILENAME").ToString();
            InsertDocs[InsertDocs.Count - 1].FileNameStartPlay = _command.Parameters.Add(":FILENAMESTARTPLAY").ToString();
            InsertDocs[InsertDocs.Count - 1].Type = Convert.ToInt32(_command.Parameters.Add(":TYPE"));
            InsertDocs[InsertDocs.Count - 1].LastEdit = Convert.ToDateTime(_command.Parameters.Add(":LASTEDIT"));
            InsertDocs[InsertDocs.Count - 1].Version = _command.Parameters.Add(":DOCVERSION").ToString();
            InsertDocs[InsertDocs.Count - 1].Thumbnail = _command.Parameters.Add(":THUMBNAIL").ToString();
            InsertDocs[InsertDocs.Count - 1].Status = Convert.ToInt32(_command.Parameters.Add(":STATUS"));
            InsertDocs[InsertDocs.Count - 1].Disclosable = Convert.ToBoolean(_command.Parameters.Add(":DISCLOSABLE"));
            InsertDocs[InsertDocs.Count - 1].ProductId = Convert.ToInt32(_command.Parameters.Add(":PRODUCTID"));
            InsertDocs[InsertDocs.Count - 1].LastUser = _command.Parameters.Add(":LAST_USER").ToString();
            InsertDocs[InsertDocs.Count - 1].LastEdit2 = Convert.ToDateTime(_command.Parameters.Add(":LAST_EDIT"));
            InsertDocs[InsertDocs.Count - 1].CategoryName = _command.Parameters.Add(":CATEGORYNAME").ToString();
            _command.ExecuteNonQuery();
     
            return InsertDocs;
        }
    }

     

     Result is the same, I did an Insert command obviously

    protected void RadGrid1_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
            {
                _BLL.InsertDocs();
            }

     

    But it's still the same.

    Any suggestions?

     

     

  2. Answer
    Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 01 Jun 2015 Link to this post

    Hello Cristina,

    I examined the provided code but since the code is not runnable it will be hard to pinpoint the reason for that behavior, Nevertheless could you please verify that InsertCommand event handler is thrown when you click the insert button. Also can you confirm that you have add the new record in the database when InsertDocuments is called?

    Regards,
    Kostadin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. CRISTINA
    CRISTINA avatar
    7 posts
    Member since:
    Jul 2010

    Posted 11 Jun 2015 in reply to Kostadin Link to this post

    Thanks. Could you please delete this post?

    Thanks.

Back to Top