本文介绍了单选按钮checkedchanged事件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的asp.net Web应用程序中,在此代码中加载rbtnCredit_CheckedChanged事件后,这两个事件(rbtnCredit_CheckedChanged,rbtnCash_CheckedChanged)不起作用
但如果先加载rbtnCash_CheckedChanged,则没有问题.
从此代码调用的这两个事件
In my asp.net web application this two event(rbtnCredit_CheckedChanged,rbtnCash_CheckedChanged) are not working after loading rbtnCredit_CheckedChanged event in this code
but no problem if first load rbtnCash_CheckedChanged.
this two event calling from this code
protected void txtVoucherNo_TextChanged(object sender, EventArgs e)
{
InvTransactionMaster objinvTransaction = new InvTransactionMaster();
_DsMaster = objinvTransaction.GetInvTransactionMaster(_voucherNumber, "SR", _BranchID, _WareHouseID, _FinancialYearID);
if (_DsMaster.Tables[0].Rows.Count > 0)
{
if (_DsMaster.Tables[0].Rows[0]["CustomerOrVendorID"].ToString() != "")
{
txtVendorIdHide.Text = _DsMaster.Tables[0].Rows[0]["CustomerOrVendorID"].ToString();
}
if (_DsMaster.Tables[0].Rows[0]["BillingMode"].ToString() == "C")
{
rbtnCash.Checked = true;
rbtnCash_CheckedChanged(null, null);
}
if (_DsMaster.Tables[0].Rows[0]["BillingMode"].ToString() == "D")
{
rbtnCredit.Checked = true;
rbtnCredit_CheckedChanged(null, null);
}
}
//事件................................
}
//events .......................
protected void rbtnCredit_CheckedChanged(object sender, EventArgs e)
{
if (rbtnCredit.Checked == true)
{
ddlCustomer.Enabled = true;
LoginDetails objlogin = (LoginDetails)Session["LoginDetils"];
int _CompanyID = Convert.ToInt32(objlogin.CompanyID.ToString());
int _BranchID = Convert.ToInt32(objlogin.BranchID.ToString());
AccountLedgerDropDown objAccount3 = new AccountLedgerDropDown(ref ddlCashAccounts);
objAccount3.DataBindForSundryDebtorsCreditorsAndCash(_CompanyID, _BranchID);
ddlCustomer_SelectedIndexChanged(null, null);
AccountLedgerDropDown objaccount = new AccountLedgerDropDown(ref txtVendorIdHide);
objaccount.GetCustomerID(Convert.ToInt32(ddlCustomer.SelectedValue), _BranchID);
}
}
protected void rbtnCash_CheckedChanged(object sender, EventArgs e)
{
if (rbtnCash.Checked == true)
{
ddlCustomer.Enabled = false;
LoginDetails objlogin = (LoginDetails)Session["LoginDetils"];
int _CompanyID = Convert.ToInt32(objlogin.CompanyID.ToString());
int _BranchID = Convert.ToInt32(objlogin.BranchID.ToString());
//Bind All CashAccounts 100-2-5
AccountLedgerDropDown objAccount = new AccountLedgerDropDown(ref ddlCashAccounts);
objAccount.DataBindForCashLedger(_CompanyID, _BranchID);
}
}
设计规范
........
design code
........
<asp:RadioButton ID="rbtnCash" runat="server" AutoPostBack="True" Checked="true"
GroupName="UT" oncheckedchanged="rbtnCash_CheckedChanged"
TabIndex="7" Text="Cash" />
<asp:RadioButton ID="rbtnCredit" runat="server" AutoPostBack="true" TabIndex="8" GroupName="UT"
OnCheckedChanged="rbtnCredit_CheckedChanged" Text="Credit"/> <asp:RadioButton ID="rbtnCredit" runat="server" AutoPostBack="true" TabIndex="8" GroupName="UT"
OnCheckedChanged="rbtnCredit_CheckedChanged" Text="Credit"/>
推荐答案
rbtnCredit.CheckChanged +=
new System.EventHandler(rbtnCredit_CheckChanged);
所以在您的代码中它应该像这样
So in your code it should come like this
if (_DsMaster.Tables[0].Rows[0]["BillingMode"].ToString() == "C")
{
rbtnCash.Checked = true;
rbtnCash.CheckChanged +=
new System.EventHandler(rbtnCredit_CheckChanged)
}
if (_DsMaster.Tables[0].Rows[0]["BillingMode"].ToString() == "D")
{
rbtnCredit.Checked = true;
rbtnCredit.CheckChanged +=
new System.EventHandler(rbtnCredit_CheckChanged)
}
希望对您有帮助!!!!
I hope this will help you out!!!!!
这篇关于单选按钮checkedchanged事件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!