Hi,
I am inserting data in grid but i want to keep grid in edit mode if validation false. For that i am using e.canceled=true in else part.
But after that cancel is not working in one time i have to click it two times. Please help
protected void rgBankAccount_UpdateCommand(object source, GridCommandEventArgs e)
{
if (ViewState["CommandName"] != null)
strCommandName = ViewState["CommandName"].ToString();
if (e.Item.OwnerTableView.Name == "Master")
{
UserControl ParentUserControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
TextBox txtAccount = ParentUserControl.FindControl("txtAccount") as TextBox;
//Label lblError = ParentUserControl.FindControl("lblError") as Label;
RadDatePicker rdpAsof = ParentUserControl.FindControl("rdpAsof") as RadDatePicker;
RadNumericTextBox RNTXTAccountNumber = ParentUserControl.FindControl("RNTXTAccountNumber") as RadNumericTextBox;
RadNumericTextBox RNTXTBeginningBalance = ParentUserControl.FindControl("RNTXTBeginningBalance") as RadNumericTextBox;
if (strCommandName == "Update")
{
int AccountID = 0;
if (ViewState["AccountID"] != null)
AccountID = Convert.ToInt32(ViewState["AccountID"].ToString());
int AccountCount = objGetData.GetAccountExist(txtAccount.Text, AccountID, GroupID);
if (AccountCount == 0)
{
objUpdateData.UpdateBankAccount(AccountID, rdpAsof.SelectedDate.ToString(), txtAccount.Text, RNTXTAccountNumber.Text, Convert.ToDouble(RNTXTBeginningBalance.Text));
ViewState["AccountID"] = null;
lblError.Visible = false;
}
else
{
lblError.Visible = true;
lblError.Text = "Please select another name";
e.Canceled = true; *********************************** //// I have used it here
}
}
else
{
int AccountCount = objGetData.GetAccountExist(txtAccount.Text, 0, GroupID);
if (AccountCount == 0)
{
objAddData.AddBankAccount(rdpAsof.SelectedDate.ToString(), txtAccount.Text, RNTXTAccountNumber.Text, Convert.ToDouble(RNTXTBeginningBalance.Text), GroupID);
lblError.Visible = false;
}
else
{
lblError.Visible = true;
lblError.Text = "Please select another name";
e.Canceled = true; *********************************** //// I have used it here
}
}
}
}
Thanks
Manish
I am inserting data in grid but i want to keep grid in edit mode if validation false. For that i am using e.canceled=true in else part.
But after that cancel is not working in one time i have to click it two times. Please help
protected void rgBankAccount_UpdateCommand(object source, GridCommandEventArgs e)
{
if (ViewState["CommandName"] != null)
strCommandName = ViewState["CommandName"].ToString();
if (e.Item.OwnerTableView.Name == "Master")
{
UserControl ParentUserControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
TextBox txtAccount = ParentUserControl.FindControl("txtAccount") as TextBox;
//Label lblError = ParentUserControl.FindControl("lblError") as Label;
RadDatePicker rdpAsof = ParentUserControl.FindControl("rdpAsof") as RadDatePicker;
RadNumericTextBox RNTXTAccountNumber = ParentUserControl.FindControl("RNTXTAccountNumber") as RadNumericTextBox;
RadNumericTextBox RNTXTBeginningBalance = ParentUserControl.FindControl("RNTXTBeginningBalance") as RadNumericTextBox;
if (strCommandName == "Update")
{
int AccountID = 0;
if (ViewState["AccountID"] != null)
AccountID = Convert.ToInt32(ViewState["AccountID"].ToString());
int AccountCount = objGetData.GetAccountExist(txtAccount.Text, AccountID, GroupID);
if (AccountCount == 0)
{
objUpdateData.UpdateBankAccount(AccountID, rdpAsof.SelectedDate.ToString(), txtAccount.Text, RNTXTAccountNumber.Text, Convert.ToDouble(RNTXTBeginningBalance.Text));
ViewState["AccountID"] = null;
lblError.Visible = false;
}
else
{
lblError.Visible = true;
lblError.Text = "Please select another name";
e.Canceled = true; *********************************** //// I have used it here
}
}
else
{
int AccountCount = objGetData.GetAccountExist(txtAccount.Text, 0, GroupID);
if (AccountCount == 0)
{
objAddData.AddBankAccount(rdpAsof.SelectedDate.ToString(), txtAccount.Text, RNTXTAccountNumber.Text, Convert.ToDouble(RNTXTBeginningBalance.Text), GroupID);
lblError.Visible = false;
}
else
{
lblError.Visible = true;
lblError.Text = "Please select another name";
e.Canceled = true; *********************************** //// I have used it here
}
}
}
}
Thanks
Manish