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;
}