how can i save multiple record in single click using user define data type in SQL
i am having problem in selecting the value in gridview using checkbox

here my code

View

// View LAyer 
    protected void imgbtnSave_Click(object sender, EventArgs e)
        {

            DataTable dtTable = new DataTable();
            DataRow dtRow = dtTable.NewRow();
           for (int i = 0; i < gvTaggingAccounts.Rows.Count; i++)
              {
                  GridViewRow row = gvTaggingAccounts.Rows[i];

                  bool isChecked = ((CheckBox)row.FindControl("chkTypes")).Checked;

               if(isChecked)
                {
                    dtRow["AccountNUM"] = gvTaggingAccounts.Rows[i].Cells[1].Text; //having error here.. not belong to the table.. 
                    dtRow["Accoutname"] = gvTaggingAccounts.Rows[i].Cells[2].Text;
                   dtTable.Rows.Add(dtRow);
                    _taggingAccountsManager.InsertAXPerDepartment();
                } 
            }
        }
       // DLSQL Layer 


            public override bool InsertAXPerDepartment()
            {
                var isSuccess = false;
                try
                {

                    _sqlHelper.CreateConnection();
                    _sqlHelper.CreateCommand("usp_InsertAXPerDepartment");

                    _sqlHelper.ExecuteNonQuery();

                }
                catch (Exception ex)
                {

                    ErrorHandler.Handle(ex);
                    OnRaiseErrorOccuredEvent(this, new ErrorEventArgs(ex));

                }
                finally
                {
                    _sqlHelper.CloseConnection();

                }
                return isSuccess;

            }



            public override bool InsertAXPerDepartment(DataTable AcctTag)
            {
                var isSuccess = false;

                try
                {

                    _sqlHelper.CreateConnection();
                    _sqlHelper.CreateCommand("usp_InsertAXPerDepartment");
                    _sqlHelper.Command.CommandType = CommandType.StoredProcedure;
                    _sqlHelper.Command.Parameters.Add("@AcctTag" ,SqlDbType.Structured);
                    SqlParameter Param = _sqlHelper.Command.Parameters.Add("@AcctTag", SqlDbType.Structured);
                    Param.Value = AcctTag;



                    ErrorHandler.Handle(ex);
                    OnRaiseErrorOccuredEvent(this, new ErrorEventArgs(ex));

                }
                finally
                {
                    _sqlHelper.CloseConnection();

                }
                return isSuccess;
            }


            my user define table is working together with the stored proc..

            anyone can solve this problem.. 


            thanks 




    protected void imgbtnSave_Click(object sender, EventArgs e)
        {

            DataTable dtTable = new DataTable();
            DataRow dtRow = dtTable.NewRow();
           for (int i = 0; i < gvTaggingAccounts.Rows.Count; i++)
              {
                  GridViewRow row = gvTaggingAccounts.Rows[i];

                  bool isChecked = ((CheckBox)row.FindControl("chkTypes")).Checked;

               if(isChecked)
                {
                    dtRow["AccountNUM"] = gvTaggingAccounts.Rows[i].Cells[1].Text; //having error here.. not belong to the table.. 
                    dtRow["Accoutname"] = gvTaggingAccounts.Rows[i].Cells[2].Text;
                   dtTable.Rows.Add(dtRow);
                    _taggingAccountsManager.InsertAXPerDepartment();
                } 
            }
        }
        DLSQL


            public override bool InsertAXPerDepartment()
            {
                var isSuccess = false;
                try
                {

                    _sqlHelper.CreateConnection();
                    _sqlHelper.CreateCommand("usp_InsertAXPerDepartment");

                    _sqlHelper.ExecuteNonQuery();

                }
                catch (Exception ex)
                {

                    ErrorHandler.Handle(ex);
                    OnRaiseErrorOccuredEvent(this, new ErrorEventArgs(ex));

                }
                finally
                {
                    _sqlHelper.CloseConnection();

                }
                return isSuccess;

            }



            public override bool InsertAXPerDepartment(DataTable AcctTag)
            {
                var isSuccess = false;

                try
                {

                    _sqlHelper.CreateConnection();
                    _sqlHelper.CreateCommand("usp_InsertAXPerDepartment");
                    _sqlHelper.Command.CommandType = CommandType.StoredProcedure;
                    _sqlHelper.Command.Parameters.Add("@AcctTag" ,SqlDbType.Structured);
                    SqlParameter Param = _sqlHelper.Command.Parameters.Add("@AcctTag", SqlDbType.Structured);
                    Param.Value = AcctTag;



                    ErrorHandler.Handle(ex);
                    OnRaiseErrorOccuredEvent(this, new ErrorEventArgs(ex));

                }
                finally
                {
                    _sqlHelper.CloseConnection();

                }
                return isSuccess;
            }

Is AccountNUM the correct name for the row?

Just checking, you have one column called AccountNUM and the other Accountname.
Can you put the contents of that cell of the gridview into a string variable?

@hericles.. I already solve my problem. but another problem may arise in my code.. how can i read the selected value of the gridview while it is on paging mode.. i can't read the value of another record if it is on the first page..

any idea?

@cyberdaemon - if you solved the question you originally asked, it may help future readers to know what that solution was.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.