By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,837 Members | 1,629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,837 IT Pros & Developers. It's quick & easy.

DropDownListBox Bug.

P: n/a
I think we have some bug in dropdownlistbox server control. Following are the values.

<asp:DropDownList id="DropDownList1" runat="server">
<asp:ListItem value="46">INR</asp:ListItem>
<asp:ListItem value="2">USE</asp:ListItem>
<asp:ListItem value="1">USD</asp:ListItem>
<asp:ListItem value="1">URO</asp:ListItem>
<asp:ListItem value="29">SND</asp:ListItem>
<asp:ListItem value="46.09">INP</asp:ListItem>
<asp:ListItem value="47">IDR</asp:ListItem>
<asp:ListItem value=".7">EURO</asp:ListItem>
<asp:ListItem value="70">EUR</asp:ListItem>
</asp:DropDownList>

Now when ever you select USD or URO option it always returns selectindex as "2". This is very strange and seems to be like a bug.

Can someone tell me wheather its know bug and if so what is the way around to solve this.

Regards,

Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Check out whether you are binding your datagrid or setting selected value for dropdownlist in page_load without checking for ispostback().

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com

<Jignesh> wrote in message news:uo**************@TK2MSFTNGP10.phx.gbl...
I think we have some bug in dropdownlistbox server control. Following are the values.

<asp:DropDownList id="DropDownList1" runat="server">
<asp:ListItem value="46">INR</asp:ListItem>
<asp:ListItem value="2">USE</asp:ListItem>
<asp:ListItem value="1">USD</asp:ListItem>
<asp:ListItem value="1">URO</asp:ListItem>
<asp:ListItem value="29">SND</asp:ListItem>
<asp:ListItem value="46.09">INP</asp:ListItem>
<asp:ListItem value="47">IDR</asp:ListItem>
<asp:ListItem value=".7">EURO</asp:ListItem>
<asp:ListItem value="70">EUR</asp:ListItem>
</asp:DropDownList>

Now when ever you select USD or URO option it always returns selectindex as "2". This is very strange and seems to be like a bug.

Can someone tell me wheather its know bug and if so what is the way around to solve this.

Regards,

Nov 18 '05 #2

P: n/a
No Saravana, Values are hardcoded. there is noting in page_load event.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Write(Me.DropDownList1.SelectedIndex.ToSt ring())
Response.Write(Me.DropDownList1.SelectedItem.Text)
End Sub

"Saravana [MVP]" <sa******@sct.co.in.nospam> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Check out whether you are binding your datagrid or setting selected value for dropdownlist in page_load without checking for ispostback().

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com

<Jignesh> wrote in message news:uo**************@TK2MSFTNGP10.phx.gbl...
I think we have some bug in dropdownlistbox server control. Following are the values.

<asp:DropDownList id="DropDownList1" runat="server">
<asp:ListItem value="46">INR</asp:ListItem>
<asp:ListItem value="2">USE</asp:ListItem>
<asp:ListItem value="1">USD</asp:ListItem>
<asp:ListItem value="1">URO</asp:ListItem>
<asp:ListItem value="29">SND</asp:ListItem>
<asp:ListItem value="46.09">INP</asp:ListItem>
<asp:ListItem value="47">IDR</asp:ListItem>
<asp:ListItem value=".7">EURO</asp:ListItem>
<asp:ListItem value="70">EUR</asp:ListItem>
</asp:DropDownList>

Now when ever you select USD or URO option it always returns selectindex as "2". This is very strange and seems to be like a bug.

Can someone tell me wheather its know bug and if so what is the way around to solve this.

Regards,

Nov 18 '05 #3

P: n/a
Jos
><Jignesh> wrote in message news:uo**************@TK2MSFTNGP10.phx.gbl...
I think we have some bug in dropdownlistbox server control. Following are the values.
<asp:DropDownList id="DropDownList1" runat="server">
<asp:ListItem value="46">INR</asp:ListItem>
<asp:ListItem value="2">USE</asp:ListItem>
<asp:ListItem value="1">USD</asp:ListItem>
<asp:ListItem value="1">URO</asp:ListItem>
<asp:ListItem value="29">SND</asp:ListItem>
<asp:ListItem value="46.09">INP</asp:ListItem>
<asp:ListItem value="47">IDR</asp:ListItem>
<asp:ListItem value=".7">EURO</asp:ListItem>
<asp:ListItem value="70">EUR</asp:ListItem>
</asp:DropDownList>

Now when ever you select USD or URO option it always returns selectindex as "2". This is very strange and seems to be like a bug.
Can someone tell me wheather its know bug and if so what is the way around to solve this.
Regards,


It's logical, because it's the value that is posted back. ASP.NET
looks it up and returns the first index that matches this value.
I guess that any other server-side script would give you the same problem.

I would try to make the values different (e.g. "1" and "1.0")

--

Jos Branders
Nov 18 '05 #4

P: n/a
No its not a bug. You have duplicate values in the drop down list.

Do you know how a regular HTML select control works? Which is what the dropdownlist control gets drawn as in the browser. When a postback happens the name of the control and the value is sent back from an HTML form. In this example, if you pick USD or URO, it would be something like DropDownList1=1. Notice its not the index that gets sent back but the value. This is how HTML works. ASP.NET has no way of knowing which one you meant and it picks the first one it finds with the identical value.
<Jignesh> wrote in message news:uo**************@TK2MSFTNGP10.phx.gbl...
I think we have some bug in dropdownlistbox server control. Following are the values.

<asp:DropDownList id="DropDownList1" runat="server">
<asp:ListItem value="46">INR</asp:ListItem>
<asp:ListItem value="2">USE</asp:ListItem>
<asp:ListItem value="1">USD</asp:ListItem>
<asp:ListItem value="1">URO</asp:ListItem>
<asp:ListItem value="29">SND</asp:ListItem>
<asp:ListItem value="46.09">INP</asp:ListItem>
<asp:ListItem value="47">IDR</asp:ListItem>
<asp:ListItem value=".7">EURO</asp:ListItem>
<asp:ListItem value="70">EUR</asp:ListItem>
</asp:DropDownList>

Now when ever you select USD or URO option it always returns selectindex as "2". This is very strange and seems to be like a bug.

Can someone tell me wheather its know bug and if so what is the way around to solve this.

Regards,

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.