错误:在DropDown列表中,Selectindex等于-1 [英] Error : in DropDown list Selectindex is equal to -1

查看:104
本文介绍了错误:在DropDown列表中,Selectindex等于-1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





当我们从 Datatable <更新下拉列表时/ code>,该值无法插入 Dropdownlist 它仅显示空白,因为选择了Index = -1



请帮我解决这个问题。



更新期间

Hi,

When we are updating the Dropdownlist from the Datatable, the value can not insert into the Dropdownlist it is showing blank only due to selected Index = -1

Kindly help me to resolve this issue.

During Update

ddlcountry.text = dtCountry[0]["Country"].Tostring();



来自数据库dtCountry =''America ''



IN下拉列表来源


from database dtCountry = ''America''

IN Dropdownlist Source

<asp:UpdatePanel ID="UpdatePanel4" runat="server">
   <ContentTemplate>
      <asp:DropDownList ID="ddlCountry" AutoPostBack ="true"

AppendDataBoundItems ="True" runat="server"

onselectedindexchanged="ddlCountry_SelectedIndexChanged"  Width="200px" >
      </asp:DropDownList>
   </ContentTemplate>
   <Triggers>
    <asp:AsyncPostBackTrigger ControlID ="ddlCountry"

   </Triggers>
</asp:UpdatePanel>

推荐答案

下拉所选索引总是从0开始。所以请将选定的下拉列表指定为0或更多。
Drop down selected index always starts from 0. So please give selected index of dropdown as 0 or more then it.


这篇关于错误:在DropDown列表中,Selectindex等于-1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆