473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Dropdown list issues

I faced 2 isseues. First, I created three (3) dropdown list on my
page. They are populated by an event triggered in the page load
command.

What's strange is that the frist drop downlist gets populated as
expected but the second and third do not get populated at all. I dont
think I made any mistake but can anyone verfiy if I made an error
somewhere?

here is my onload code:

Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class supervisor_keyword
Inherits System.Web.UI.Page
Dim strconnectionString As String =
WebConfigurationManager.ConnectionStrings("LocalSq lServer").ConnectionString
Dim con As New SqlConnection(strconnectionString)
Dim cmd As New SqlCommand("", con)
Dim recordcount As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim myda As SqlDataAdapter
Dim ds As Data.DataSet
myda = New SqlDataAdapter("SELECT * from gown_AdminStocks",
strconnectionString)
ds = New Data.DataSet
myda.Fill(ds, "AllTables")
GridViewStocks.DataSource = ds
GridViewStocks.DataSource = ds.Tables(0)

GridViewStocks.DataBind()
DropDownListSize.DataSource = ds
DropDownListSize.DataSource = ds.Tables(0)

DropDownListSize.DataTextField =
ds.Tables(0).Columns("SizeID").ColumnName.ToString ()
DropDownListSize.DataValueField =
ds.Tables(0).Columns("SizeID").ColumnName.ToString ()
DropDownListSize.DataBind()

Dim mydaprice As SqlDataAdapter
Dim dsprice As Data.DataSet
mydaprice = New SqlDataAdapter("SELECT * from
gown_AdminCost", strconnectionString)
dsprice = New Data.DataSet
mydaprice.Fill(dsprice, "CostTables")
GridViewPriceGrid.DataSource = dsprice
GridViewPriceGrid.DataSource = dsprice.Tables(0)
GridViewPriceGrid.DataBind()
DropDownPriceGrid.DataTextField =
dsprice.Tables(0).Columns("CostType").ColumnName.T oString()
DropDownPriceGrid.DataValueField =
dsprice.Tables(0).Columns("CostID").ColumnName.ToS tring()
DropDownPriceGrid.DataBind()
Dim mydakey As SqlDataAdapter
Dim dskey As Data.DataSet
mydakey = New SqlDataAdapter("SELECT * from
gown_AdminKeyword", strconnectionString)
dskey = New Data.DataSet
mydakey.Fill(dskey, "KeywordTables")
GridViewKeywords.DataSource = dskey
GridViewKeywords.DataSource = dskey.Tables("KeywordTables")
GridViewKeywords.DataBind()
DropDownListKeyword.DataTextField =
dskey.Tables(0).Columns("Keyword").ColumnName.ToSt ring()
DropDownListKeyword.DataValueField =
dskey.Tables(0).Columns("KeywordID").ColumnName.To String()
DropDownListKeyword.DataBind()

End Sub
End Class

Secondly, when I select the items in the first dropdownlist, It only
returns the value of the first item, irregardless of what has been
selected. This is strnage as I have done this something similar but
never run into this issues. Any thought?

Thanks in advance.

May 20 '07 #1
3 1230
1.You don't seem to set datasource for the second and third ddl.

2.You always reload the first ddl on every postback. Databind it only if
IsPostBack is false.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Fendi Baba" <ef*****@epitome.com.sgwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
>I faced 2 isseues. First, I created three (3) dropdown list on my
page. They are populated by an event triggered in the page load
command.

What's strange is that the frist drop downlist gets populated as
expected but the second and third do not get populated at all. I dont
think I made any mistake but can anyone verfiy if I made an error
somewhere?

here is my onload code:

Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class supervisor_keyword
Inherits System.Web.UI.Page
Dim strconnectionString As String =
WebConfigurationManager.ConnectionStrings("LocalSq lServer").ConnectionString
Dim con As New SqlConnection(strconnectionString)
Dim cmd As New SqlCommand("", con)
Dim recordcount As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim myda As SqlDataAdapter
Dim ds As Data.DataSet
myda = New SqlDataAdapter("SELECT * from gown_AdminStocks",
strconnectionString)
ds = New Data.DataSet
myda.Fill(ds, "AllTables")
GridViewStocks.DataSource = ds
GridViewStocks.DataSource = ds.Tables(0)

GridViewStocks.DataBind()
DropDownListSize.DataSource = ds
DropDownListSize.DataSource = ds.Tables(0)

DropDownListSize.DataTextField =
ds.Tables(0).Columns("SizeID").ColumnName.ToString ()
DropDownListSize.DataValueField =
ds.Tables(0).Columns("SizeID").ColumnName.ToString ()
DropDownListSize.DataBind()

Dim mydaprice As SqlDataAdapter
Dim dsprice As Data.DataSet
mydaprice = New SqlDataAdapter("SELECT * from
gown_AdminCost", strconnectionString)
dsprice = New Data.DataSet
mydaprice.Fill(dsprice, "CostTables")
GridViewPriceGrid.DataSource = dsprice
GridViewPriceGrid.DataSource = dsprice.Tables(0)
GridViewPriceGrid.DataBind()
DropDownPriceGrid.DataTextField =
dsprice.Tables(0).Columns("CostType").ColumnName.T oString()
DropDownPriceGrid.DataValueField =
dsprice.Tables(0).Columns("CostID").ColumnName.ToS tring()
DropDownPriceGrid.DataBind()
Dim mydakey As SqlDataAdapter
Dim dskey As Data.DataSet
mydakey = New SqlDataAdapter("SELECT * from
gown_AdminKeyword", strconnectionString)
dskey = New Data.DataSet
mydakey.Fill(dskey, "KeywordTables")
GridViewKeywords.DataSource = dskey
GridViewKeywords.DataSource = dskey.Tables("KeywordTables")
GridViewKeywords.DataBind()
DropDownListKeyword.DataTextField =
dskey.Tables(0).Columns("Keyword").ColumnName.ToSt ring()
DropDownListKeyword.DataValueField =
dskey.Tables(0).Columns("KeywordID").ColumnName.To String()
DropDownListKeyword.DataBind()

End Sub
End Class

Secondly, when I select the items in the first dropdownlist, It only
returns the value of the first item, irregardless of what has been
selected. This is strnage as I have done this something similar but
never run into this issues. Any thought?

Thanks in advance.

May 20 '07 #2
On May 20, 3:42 pm, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
1.You don't seem to set datasource for the second and third ddl.

2.You always reload the first ddl on every postback. Databind it only if
IsPostBack is false.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

"Fendi Baba" <effe...@epitome.com.sgwrote in message

news:11**********************@q75g2000hsh.googlegr oups.com...
I faced 2 isseues. First, I created three (3) dropdown list on my
page. They are populated by an event triggered in the page load
command.
What's strange is that the frist drop downlist gets populated as
expected but the second and third do not get populated at all. I dont
think I made any mistake but can anyone verfiy if I made an error
somewhere?
here is my onload code:
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class supervisor_keyword
Inherits System.Web.UI.Page
Dim strconnectionString As String =
WebConfigurationManager.ConnectionStrings("LocalSq lServer").ConnectionStrin*g
Dim con As New SqlConnection(strconnectionString)
Dim cmd As New SqlCommand("", con)
Dim recordcount As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim myda As SqlDataAdapter
Dim ds As Data.DataSet
myda = New SqlDataAdapter("SELECT * from gown_AdminStocks",
strconnectionString)
ds = New Data.DataSet
myda.Fill(ds, "AllTables")
GridViewStocks.DataSource = ds
GridViewStocks.DataSource = ds.Tables(0)
GridViewStocks.DataBind()
DropDownListSize.DataSource = ds
DropDownListSize.DataSource = ds.Tables(0)
DropDownListSize.DataTextField =
ds.Tables(0).Columns("SizeID").ColumnName.ToString ()
DropDownListSize.DataValueField =
ds.Tables(0).Columns("SizeID").ColumnName.ToString ()
DropDownListSize.DataBind()
Dim mydaprice As SqlDataAdapter
Dim dsprice As Data.DataSet
mydaprice = New SqlDataAdapter("SELECT * from
gown_AdminCost", strconnectionString)
dsprice = New Data.DataSet
mydaprice.Fill(dsprice, "CostTables")
GridViewPriceGrid.DataSource = dsprice
GridViewPriceGrid.DataSource = dsprice.Tables(0)
GridViewPriceGrid.DataBind()
DropDownPriceGrid.DataTextField =
dsprice.Tables(0).Columns("CostType").ColumnName.T oString()
DropDownPriceGrid.DataValueField =
dsprice.Tables(0).Columns("CostID").ColumnName.ToS tring()
DropDownPriceGrid.DataBind()
Dim mydakey As SqlDataAdapter
Dim dskey As Data.DataSet
mydakey = New SqlDataAdapter("SELECT * from
gown_AdminKeyword", strconnectionString)
dskey = New Data.DataSet
mydakey.Fill(dskey, "KeywordTables")
GridViewKeywords.DataSource = dskey
GridViewKeywords.DataSource = dskey.Tables("KeywordTables")
GridViewKeywords.DataBind()
DropDownListKeyword.DataTextField =
dskey.Tables(0).Columns("Keyword").ColumnName.ToSt ring()
DropDownListKeyword.DataValueField =
dskey.Tables(0).Columns("KeywordID").ColumnName.To String()
DropDownListKeyword.DataBind()
End Sub
End Class
Secondly, when I select the items in the first dropdownlist, It only
returns the value of the first item, irregardless of what has been
selected. This is strnage as I have done this something similar but
never run into this issues. Any thought?
Thanks in advance.- Hide quoted text -

- Show quoted text -
Elliyahu

1. In both the second and third ddl, i set these respectively:

Dim mydaprice As SqlDataAdapter
Dim dsprice As Data.DataSet
mydaprice = New SqlDataAdapter("SELECT * from
gown_AdminCost", strconnectionString)
dsprice = New Data.DataSet
mydaprice.Fill(dsprice, "CostTables")
DropDownPriceGrid.DataBind()

and
Dim mydakey As SqlDataAdapter
Dim dskey As Data.DataSet
mydakey = New SqlDataAdapter("SELECT * from
gown_AdminKeyword", strconnectionString)
dskey = New Data.DataSet
mydakey.Fill(dskey, "KeywordTables")

DropDownListKeyword.DataBind()
>

Is this done wrongly?

Thanks gfor your input. I think the Ispost back issue might be the
cause of the second problem.

May 20 '07 #3
On May 20, 6:14 pm, Fendi Baba <effe...@epitome.com.sgwrote:
On May 20, 3:42 pm, "Eliyahu Goldin"

<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
1.You don't seem to set datasource for the second and third ddl.
2.You always reload the first ddl on every postback. Databind it only if
IsPostBack is false.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
"Fendi Baba" <effe...@epitome.com.sgwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
>I faced 2 isseues. First, I created three (3) dropdown list on my
page. They are populated by an event triggered in the page load
command.
What's strange is that the frist drop downlist gets populated as
expected but the second and third do not get populated at all. I dont
think I made any mistake but can anyone verfiy if I made an error
somewhere?
here is my onload code:
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class supervisor_keyword
Inherits System.Web.UI.Page
Dim strconnectionString As String =
WebConfigurationManager.ConnectionStrings("LocalSq lServer").ConnectionStrin**g
Dim con As New SqlConnection(strconnectionString)
Dim cmd As New SqlCommand("", con)
Dim recordcount As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim myda As SqlDataAdapter
Dim ds As Data.DataSet
myda = New SqlDataAdapter("SELECT * from gown_AdminStocks",
strconnectionString)
ds = New Data.DataSet
myda.Fill(ds, "AllTables")
GridViewStocks.DataSource = ds
GridViewStocks.DataSource = ds.Tables(0)
GridViewStocks.DataBind()
DropDownListSize.DataSource = ds
DropDownListSize.DataSource = ds.Tables(0)
DropDownListSize.DataTextField =
ds.Tables(0).Columns("SizeID").ColumnName.ToString ()
DropDownListSize.DataValueField =
ds.Tables(0).Columns("SizeID").ColumnName.ToString ()
DropDownListSize.DataBind()
Dim mydaprice As SqlDataAdapter
Dim dsprice As Data.DataSet
mydaprice = New SqlDataAdapter("SELECT * from
gown_AdminCost", strconnectionString)
dsprice = New Data.DataSet
mydaprice.Fill(dsprice, "CostTables")
GridViewPriceGrid.DataSource = dsprice
GridViewPriceGrid.DataSource = dsprice.Tables(0)
GridViewPriceGrid.DataBind()
DropDownPriceGrid.DataTextField =
dsprice.Tables(0).Columns("CostType").ColumnName.T oString()
DropDownPriceGrid.DataValueField =
dsprice.Tables(0).Columns("CostID").ColumnName.ToS tring()
DropDownPriceGrid.DataBind()
Dim mydakey As SqlDataAdapter
Dim dskey As Data.DataSet
mydakey = New SqlDataAdapter("SELECT * from
gown_AdminKeyword", strconnectionString)
dskey = New Data.DataSet
mydakey.Fill(dskey, "KeywordTables")
GridViewKeywords.DataSource = dskey
GridViewKeywords.DataSource = dskey.Tables("KeywordTables")
GridViewKeywords.DataBind()
DropDownListKeyword.DataTextField =
dskey.Tables(0).Columns("Keyword").ColumnName.ToSt ring()
DropDownListKeyword.DataValueField =
dskey.Tables(0).Columns("KeywordID").ColumnName.To String()
DropDownListKeyword.DataBind()
End Sub
End Class
Secondly, when I select the items in the first dropdownlist, It only
returns the value of the first item, irregardless of what has been
selected. This is strnage as I have done this something similar but
never run into this issues. Any thought?
Thanks in advance.- Hide quoted text -
- Show quoted text -

Elliyahu

1. In both the second and third ddl, i set these respectively:
Dim mydaprice As SqlDataAdapter
Dim dsprice As Data.DataSet
mydaprice = New SqlDataAdapter("SELECT * from
gown_AdminCost", strconnectionString)
dsprice = New Data.DataSet
mydaprice.Fill(dsprice, "CostTables")

DropDownPriceGrid.DataBind()

and

Dim mydakey As SqlDataAdapter
Dim dskey As Data.DataSet
mydakey = New SqlDataAdapter("SELECT * from
gown_AdminKeyword", strconnectionString)
dskey = New Data.DataSet
mydakey.Fill(dskey, "KeywordTables")

DropDownListKeyword.DataBind()

Is this done wrongly?

Thanks gfor your input. I think the Ispost back issue might be the
cause of the second problem.- Hide quoted text -

- Show quoted text -
Elliyahu

I saw the problem with the datasource. Thanks for pointing it out.

Regards

May 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Marc | last post by:
I've gotten everything up and running except for this -- I'd like to be able to have people have a dropdown list of cities in the US to use (or wherever) and not have to input them manually into a...
1
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two...
2
by: JP SIngh | last post by:
Hi All I just wondering if someone can suggest a solution to this tricky issue we have got. I have an asp form which allow our users to create a new record and save it to the database. On the...
1
by: t.kiesche | last post by:
Hello I want to make a textfield (INPUT type=text) or something that looklike this, to drop down a list with word. Just like: A user writes the letter 'a' and in the dropdown list come a...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
0
by: =?Utf-8?B?THluZGE=?= | last post by:
Using VB dot net web application, a page uses the drop down list web control. When running on my XP Pro from within Visual Studio or when running from http://localhost, the dropdown list does not...
4
by: phcmi | last post by:
I have a PropertyGrid question. My task is to replace a legacy dialog box presentation with a modern one. The dialog itself allows the user to set configuration settings in our application, so...
3
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I need to show a custom control in the DropDown of a Windows.Forms.ToolStripMenuItem (e.g., similar to the Font Color menu item in Word except that the control is specific to my application). I...
5
by: =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== | last post by:
I have a VS 2008 ASP.NET webform that has a reportview tag on it, accessing an .RLDC report in local report. The columns for the report are essentially: Month Item #1 Item#2 Item#3 ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.