0
我有一个asp组合框内的更新面板与autopost回设置为true。
在页面加载我填组合框中Combobox'OnSelectedIndexChanged'没有触发某些值
public DataTable getProductDetails()
{
MasterAllocationDB dataHandler = new MasterAllocationDB();
DataTable dataBoxType = null;
DataRow row = null;
try
{
dataBoxType = dataHandler.GetBoxType();
if (dataBoxType != null && dataBoxType.Rows.Count > 0)
{
row = dataBoxType.NewRow();
row["Product"] = "--Select--";
dataBoxType.Rows.InsertAt(row,0);
row = dataBoxType.NewRow();
row["Product"] = "Other";
dataBoxType.Rows.InsertAt(row, dataBoxType.Rows.Count);
}
}
catch (Exception ex)
{
LogHandler.LogMessageToFile(ex, LogMode.Fatal);
}
return dataBoxType;
}
另外我有一个onselectedindexchanged
事件绑定
protected void productComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
string json = null;
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row = null;
var s = this.productComboBox.SelectedValue;
try
{
int totalNoOfItems = this.productComboBox.Items.Count;
// Make sure that Index are between "select a value" and "Other"
if (this.productComboBox.SelectedIndex > 0 && this.productComboBox.SelectedIndex < totalNoOfItems - 1)
{
//code here
}
json = new JavaScriptSerializer().Serialize(rows);
}
catch (Exception ex)
{
LogHandler.LogMessageToFile(ex, LogMode.Fatal);
}
}
正如你可以看到我已经添加了2个额外的行除了从DB.The数据获取的行行是正确绑定,因为我可以看到相同的输出组合框中的值
运行后,我注意到,只要我选择“其他”,组合框中的文本变得更改
为“ - 选择 - ”和控制永不到达onselectedindexchanged
它适用于所有其他情况。可能是什么原因?
你可以显示'onselectindexchanged'的代码吗? – sr28
@ sr28增加了它的问题 –