如何通过下拉列表更改事件触发一次解决问题然后跳过一个更改事件然后再次触发然后跳过(替换更改事件触发)...等等? [英] How do I solve problem with dropdownlist change event firing once then skips one change event then fires again then skips(alternate change event firing)... And so on ?
问题描述
我在更新面板中有一个下拉列表。它可以在多台机器上正常工作,但在特定的机器上它适用于其他更换事件。
示例:
最初设置为0索引选择序列号
当我选择说SrNo1时,更改事件不会触发
当我选择说SrNo2时,更改事件触发
当我选择说SrNo3时,更改事件不会触发
当我选择说SrNo4时,更改事件火灾
等等......
代码:
受保护 void ddlCollection_SelectedIndexChanged( object sender,EventArgs e)
{
ddlSerial.SelectedIndex = -1;
hdfQDSID.Value = ;
txtQuantity.Text = ;
lblTypeT.Text = ;
lblQds.Text = ;
lnkWHStock.Text = ;
lblPieces.Text = ;
lblUnit.Text = ;
string CollectionID = ddlCollection.SelectedValue.ToString();
if (ddlCollection.SelectedValue.ToString()!= 0)
{
DataTable dt = new DataTable();
DataSet ds = objBAL.getGridCollectionSrNo(CollectionID.ToString());
if (ds.Tables [ 1 ]。行[ 0 ] [ COLLECTION_STATUS]。ToString() == DISCONTINUED)
{
ScriptManager.RegisterStartupScript(Page,GetType (), CollectionDscontiAler, < script> alert('此集合已停止。');< / script>, false 跨度>);
}
dt = ds.Tables [ 0 ];
ddlSerial.DataSource = dt;
ddlSerial.DataTextField = SR_NO;
ddlSerial.DataValueField = SR_NO;
ddlSerial.DataBind();
ddlSerial.Items.Insert( 0 , new System.Web.UI.WebControls.ListItem ( 选择Sr否, 0));
ddlSerial.SelectedIndex = 0 ;
}
}
< pre lang =C#> protected void ddlSerial_SelectedIndexChanged( object sender,EventArgs e)
{
hdfQDSID.Value = 跨度>;
txtQuantity.Text = ;
lblTypeT.Text = ;
lblQds.Text = ;
lnkWHStock.Text = ;
lblPieces.Text = ;
lblUnit.Text = ;
string QDSName = string .Empty;
string QDSID = string .Empty;
string TypeOfFabric = string .Empty;
string CollectionID = ddlCollection.SelectedValue.ToString();
string SrNo = ddlSerial.SelectedValue.ToString();
如果(SrNo!= 0&& CollectionID!= 0 )
{
DataTable dt = new DataTable();
DataSet dsQdsName = objBAL.getGridCollectionQDS(CollectionID,SrNo); // uspB2BCustomerPortal_uspGetCollectionQDS
dt = dsQdsName.Tables [ 0 跨度>];
if (dt.Rows.Count > 0 )
{
QDSName = dt.Rows [ 0 ] [ QDSName]。ToString();
QDSID = dt.Rows [ 0 ] [ QDS_ID跨度>]的ToString();
hdfMultipleOf.Value = dt.Rows [ 0 ] [ MULTIPLE_OF跨度>]的ToString();
if (dsQdsName.Tables [ 1 ]。行[ 0 ] [ PRODUCT_STATUS]。ToString()== DISCONTINUED)
{
ScriptManager.RegisterStartupScript(Page,GetType(),< span class =code-string> QDSDiscontinuedAlertU, < script> alert('此QDS已停止。');< / script>, true );
}
}
TypeOfFabric = lblOrderTypeDesription.Text.ToString();
if (QDSName!= )
{
lblQds.Text = QDSName.ToString();
hdfQDSID.Value = QDSID.ToString();
// bool result = CheckQDSOrderForCustomer();
// if(result)
// {
if ( QDSID!= )
{
// WHStock&没有Pcs。
B2B_Order_Master_SAP_BAL obj_BAL = new B2B_Order_Master_SAP_BAL();
DataSet dsWHStockinfo = obj_BAL.getWHStock(QDSID,hfCustomerId.Value.ToString()); // usp_B2BCustomerPortal_getCreateOrderWHStock
lnkWHStock.Text = dsWHStockinfo.Tables [ 0 ]。行[ 0 ] [ WHStock跨度>]的ToString();
lblPieces.Text = dsWHStockinfo.Tables [ 0 ]。行[ 0 ] [ No_Of_Pieces]。ToString();
// if(dsWHStockinfo.Tables [0] .Rows [0] [No_Of_Pieces ] .ToString()!=)
// {
// lblPieces.ForeColor = System.Drawing.Color.Red;
// }
}
if (TypeOfFabric == Fabric Order)
{
lblUnit.Text = Mtrs。;
}
else if (TypeOfFabric == 非布料订单 || TypeOfFabric == 目录顺序)
{
lblUnit.Text = PCS跨度>;
}
// }
// else
// < span class =code-comment> {
// ScriptManager.RegisterStartupScript(Page, GetType(),Last3DaysTwo2,< script> AlertUser();< / script>,false);
// YesAlertUser.Focus();
// }
}
else
{
lblQds.Text = 未找到QDS。;
}
}
}
我尝试了什么:
我的Updatepanel如下:
< asp:UpdatePanel ID < span class =code-keyword> =
UpdatePanel1 UpdateMode = 条件 runat = server >
< contenttemplate >
< / contenttemplate >
< 触发器 >
< asp:AsyncPostBackTrigger ControlID = btnShowInfo EventName = 点击 / >
< asp:AsyncPostBackTrigger ControlID = btnAddItems EventName = 点击 / >
< asp:AsyncPostBackTrigger ControlID = ddlSerial EventName = SelectedIndexChanged / >
< ; / triggers >
< asp:UpdateProgress ID = updPanelProgress runat < span class =code-keyword> = server AssociatedUpdatePanelID = UpdatePanel1 >
< progresstemplate >
< div class = 预加载器 > < / div >
< / progresstemplate >
- 此下拉列表导致问题。它在一张桌子里
< table > < tbody < span class =code-keyword>>
< tr > < td >
< asp:DropDownList ID = ddlSerial runat = server onchange = SetScroll(); AutoPostBack = true OnSelectedIndexChanged = < span class =code-keyword> ddlSerial_SelectedIndexChanged >
< ; / td > < / tr > < / tbody > < < span class =code-leadattribute> / table >
试试这个
ScriptManager。 RegisterClientScriptBlock ( this ,GetType(), CollectionDscontiAler, < script> alert('此集合已停止。');< / script> , false );
I have a dropdown list inside update panel . it works fine on several machines but on specific machines it works on alternate change events.
Example :
Initially it is set to 0 index "Select Serial No"
When i Choose say SrNo1 , change event doesnt fire
When i choose say SrNo2, change event fires
When i Choose say SrNo3 , change event doesnt fire
When i choose say SrNo4, change event fires
and so on...
Code :
protected void ddlCollection_SelectedIndexChanged(object sender, EventArgs e)
{
ddlSerial.SelectedIndex = -1;
hdfQDSID.Value = "";
txtQuantity.Text = "";
lblTypeT.Text = "";
lblQds.Text = "";
lnkWHStock.Text = "";
lblPieces.Text = "";
lblUnit.Text = "";
string CollectionID = ddlCollection.SelectedValue.ToString();
if (ddlCollection.SelectedValue.ToString() != "0")
{
DataTable dt = new DataTable();
DataSet ds = objBAL.getGridCollectionSrNo(CollectionID.ToString());
if (ds.Tables[1].Rows[0]["COLLECTION_STATUS"].ToString() == "DISCONTINUED")
{
ScriptManager.RegisterStartupScript(Page, GetType(), "CollectionDscontiAler", "<script>alert('This Collection has been discontinued.');</script>", false);
}
dt = ds.Tables[0];
ddlSerial.DataSource = dt;
ddlSerial.DataTextField = "SR_NO";
ddlSerial.DataValueField = "SR_NO";
ddlSerial.DataBind();
ddlSerial.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Select Sr No", "0"));
ddlSerial.SelectedIndex = 0;
}
}
protected void ddlSerial_SelectedIndexChanged(object sender, EventArgs e)
{
hdfQDSID.Value = "";
txtQuantity.Text = "";
lblTypeT.Text = "";
lblQds.Text = "";
lnkWHStock.Text = "";
lblPieces.Text = "";
lblUnit.Text = "";
string QDSName = string.Empty;
string QDSID = string.Empty;
string TypeOfFabric = string.Empty;
string CollectionID = ddlCollection.SelectedValue.ToString();
string SrNo = ddlSerial.SelectedValue.ToString();
if (SrNo != "0" && CollectionID != "0")
{
DataTable dt = new DataTable();
DataSet dsQdsName = objBAL.getGridCollectionQDS(CollectionID, SrNo); //uspB2BCustomerPortal_uspGetCollectionQDS
dt = dsQdsName.Tables[0];
if (dt.Rows.Count > 0)
{
QDSName = dt.Rows[0]["QDSName"].ToString();
QDSID = dt.Rows[0]["QDS_ID"].ToString();
hdfMultipleOf.Value = dt.Rows[0]["MULTIPLE_OF"].ToString();
if (dsQdsName.Tables[1].Rows[0]["PRODUCT_STATUS"].ToString() == "DISCONTINUED")
{
ScriptManager.RegisterStartupScript(Page, GetType(), "QDSDiscontinuedAlertU", "<script>alert('This QDS has been discontinued.');</script>",true);
}
}
TypeOfFabric = lblOrderTypeDesription.Text.ToString();
if (QDSName != "")
{
lblQds.Text = QDSName.ToString();
hdfQDSID.Value = QDSID.ToString();
//bool result = CheckQDSOrderForCustomer();
//if (result)
//{
if (QDSID != "")
{
//Code for WHStock & No of Pcs.
B2B_Order_Master_SAP_BAL obj_BAL = new B2B_Order_Master_SAP_BAL();
DataSet dsWHStockinfo = obj_BAL.getWHStock(QDSID, hfCustomerId.Value.ToString()); //usp_B2BCustomerPortal_getCreateOrderWHStock
lnkWHStock.Text = dsWHStockinfo.Tables[0].Rows[0]["WHStock"].ToString();
lblPieces.Text = dsWHStockinfo.Tables[0].Rows[0]["No_Of_Pieces"].ToString();
//if (dsWHStockinfo.Tables[0].Rows[0]["No_Of_Pieces"].ToString() != "")
//{
// lblPieces.ForeColor = System.Drawing.Color.Red;
//}
}
if (TypeOfFabric == "Fabric Order")
{
lblUnit.Text = "Mtrs.";
}
else if (TypeOfFabric == "Non-Fabric Order" || TypeOfFabric == "Catalogue Order")
{
lblUnit.Text = "Pcs";
}
//}
//else
//{
// ScriptManager.RegisterStartupScript(Page, GetType(), "Last3DaysTwo2", "<script>AlertUser();</script>", false);
// YesAlertUser.Focus();
//}
}
else
{
lblQds.Text = "QDS Not Found.";
}
}
}
What I have tried:
My Updatepanel is below :
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<contenttemplate>
</contenttemplate>
<triggers>
<asp:AsyncPostBackTrigger ControlID="btnShowInfo" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnAddItems" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ddlSerial" EventName="SelectedIndexChanged" />
</triggers>
<asp:UpdateProgress ID="updPanelProgress" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<progresstemplate>
<div class="pre-loader"></div>
</progresstemplate>
-- This dropdownlist is causing problem. It is inside a table
<table><tbody><tr><td>
<asp:DropDownList ID="ddlSerial" runat="server" onchange="SetScroll();" AutoPostBack="true" OnSelectedIndexChanged="ddlSerial_SelectedIndexChanged">
</td></tr></tbody></table>
try this
ScriptManager.RegisterClientScriptBlock(this, GetType(), "CollectionDscontiAler", "<script>alert('This Collection has been discontinued.');</script>", false);
这篇关于如何通过下拉列表更改事件触发一次解决问题然后跳过一个更改事件然后再次触发然后跳过(替换更改事件触发)...等等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!