本文介绍了按钮上的Sharepoint webpart下拉列表selectedindex值始终为-1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过SPService在Webpart中绑定我的下拉列表,如下所示:
I bind my dropdownlist in Webpart through SPService like this:
$(document).ready(function () {
FillDropDown();
});
function FillDropDown() {
var index = 0;
$("#filterCountry").empty();
$().SPServices({
operation: "GetList",
listName: "Pages",
async: false,
completefunc: function (xData, Status) {
$(xData.responseXML).find("Field[DisplayName='Country'] CHOICE").each(function () {
//if (index == 0) {
// $(".filterCountry").append("<option value='0'>--Select--</option>");
//}
listItem = "<option value=" + $(this).text() + ">" + $(this).text() + "</option>";
$("#filterCountry").append(listItem);
index++;
})
}
})
下拉列表设计:
dropdownlist design :
<div class="country">
<span class="pull-left mar-top-5">Country</span>
<asp:DropDownList ID="filterCountry" runat="server" ClientIDMode="Static" CssClass="form-control pull-right country_drop_down"></asp:DropDownList>
</div>
<div class="go">
<asp:Button runat="server" CssClass="btn btn-primary" ID="btnSubmit" OnClick="btnSubmit_Click" Text="Go" />
</div>
Codeside:
Codeside:
protected void btnSubmit_Click(object sender, EventArgs e)
{
ViewState["Query"]) = null;
// BindReapterMain(Convert.ToString(ViewState["Query"]));
}
问题是当我点击Button我得到dropdownlist selectedindex总是-1而不是获得selectedindex = 2那个我已选择..请帮助任何解决方案
The issue is when i click on Button i get dropdownlist selectedindex always -1 instead of getting selectedindex = 2 that i have selected.. Please help to any solution
推荐答案
这篇关于按钮上的Sharepoint webpart下拉列表selectedindex值始终为-1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!