473,405 Members | 2,338 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,405 software developers and data experts.

dropdown list not working

SSP
I have a dropdown list on my page as:

<asp:dropdownlist id=ddJobtypes runat="server" ></asp:dropdownlist>
<asp:button id=jobtypes_btn runat="server" Text="GO!"></asp:button>

This is bound in the codebehind file as:

JobTypesDD_sqlDataAdapter.Fill(dsJobTypesDD1);
ddJobtypes.DataSource = dsJobTypesDD1;
ddJobtypes.DataTextField = "jobClassName";
ddJobtypes.DataValueField = "jobClassID";
ddJobtypes.DataBind();

When I click the button "jobtypes_btn" the following is called:

private void jobtypes_btn_Click(object sender, System.EventArgs e)
{
JobtypesSearch_sqlSelectCommand.Parameters["@jobClass"].Value =
ddJobtypes.SelectedValue.ToString();
sqlConnection1.Open();
JobtypesSearch_sqlSelectCommand.ExecuteNonQuery();
JobtypesSearch_sqlDataAdapter.Fill(dsJobTypesSearc h1);
dgJobtypesSearch.DataBind();
sqlConnection1.Close();

vacancyText_Panel.Visible = false;
JobTypes_Panel.Visible = true;
}

When I open the aspx file I get the folowing HTML code where the
dropdownlist is:
....
<select name="ddJobtypes" id="ddJobtypes">
<option value="3">Accounting and Audit Classification</option>
<option value="1">Dental Officer</option>
<option value="4">Education Officers</option>
</select><input type="submit" name="jobtypes_btn" value="GO!"
id="jobtypes_btn" />
....

When I click the jobtypes_btn button (after selecting any of the options),
it gives me the result for option value 3 and the HTML code turns:

<select name="ddJobtypes" id="ddJobtypes" class="formTxtBox">
<option selected="selected" value="3">Accounting and Audit
Classification</option>
<option value="1">Dental Officer</option>
<option value="4">Education Officers</option>
</select><input type="submit" name="jobtypes_btn" value="GO!"
id="jobtypes_btn" class="formTxtBox" />

What am I doing wrong?

SSP

Nov 17 '05 #1
3 2131
Are you checking for ispostback() before binding your dropdownlist.

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

"SSP" <ss*@dt.com> wrote in message
news:eO*************@TK2MSFTNGP11.phx.gbl...
I have a dropdown list on my page as:

<asp:dropdownlist id=ddJobtypes runat="server" ></asp:dropdownlist>
<asp:button id=jobtypes_btn runat="server" Text="GO!"></asp:button>

This is bound in the codebehind file as:

JobTypesDD_sqlDataAdapter.Fill(dsJobTypesDD1);
ddJobtypes.DataSource = dsJobTypesDD1;
ddJobtypes.DataTextField = "jobClassName";
ddJobtypes.DataValueField = "jobClassID";
ddJobtypes.DataBind();

When I click the button "jobtypes_btn" the following is called:

private void jobtypes_btn_Click(object sender, System.EventArgs e)
{
JobtypesSearch_sqlSelectCommand.Parameters["@jobClass"].Value =
ddJobtypes.SelectedValue.ToString();
sqlConnection1.Open();
JobtypesSearch_sqlSelectCommand.ExecuteNonQuery();
JobtypesSearch_sqlDataAdapter.Fill(dsJobTypesSearc h1);
dgJobtypesSearch.DataBind();
sqlConnection1.Close();

vacancyText_Panel.Visible = false;
JobTypes_Panel.Visible = true;
}

When I open the aspx file I get the folowing HTML code where the
dropdownlist is:
...
<select name="ddJobtypes" id="ddJobtypes">
<option value="3">Accounting and Audit Classification</option>
<option value="1">Dental Officer</option>
<option value="4">Education Officers</option>
</select><input type="submit" name="jobtypes_btn" value="GO!"
id="jobtypes_btn" />
...

When I click the jobtypes_btn button (after selecting any of the options),
it gives me the result for option value 3 and the HTML code turns:

<select name="ddJobtypes" id="ddJobtypes" class="formTxtBox">
<option selected="selected" value="3">Accounting and Audit
Classification</option>
<option value="1">Dental Officer</option>
<option value="4">Education Officers</option>
</select><input type="submit" name="jobtypes_btn" value="GO!"
id="jobtypes_btn" class="formTxtBox" />

What am I doing wrong?

SSP

Nov 17 '05 #2
SSP
No.

I did at once and, the resultant page had empty dropdown list with no
results.

SSP

"Saravana [MVP]" <sa******@sct.co.in.nospam> wrote in message
news:OG**************@tk2msftngp13.phx.gbl...
Are you checking for ispostback() before binding your dropdownlist.

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

"SSP" <ss*@dt.com> wrote in message
news:eO*************@TK2MSFTNGP11.phx.gbl...
I have a dropdown list on my page as:

<asp:dropdownlist id=ddJobtypes runat="server" ></asp:dropdownlist>
<asp:button id=jobtypes_btn runat="server" Text="GO!"></asp:button>

This is bound in the codebehind file as:

JobTypesDD_sqlDataAdapter.Fill(dsJobTypesDD1);
ddJobtypes.DataSource = dsJobTypesDD1;
ddJobtypes.DataTextField = "jobClassName";
ddJobtypes.DataValueField = "jobClassID";
ddJobtypes.DataBind();

When I click the button "jobtypes_btn" the following is called:

private void jobtypes_btn_Click(object sender, System.EventArgs e)
{
JobtypesSearch_sqlSelectCommand.Parameters["@jobClass"].Value =
ddJobtypes.SelectedValue.ToString();
sqlConnection1.Open();
JobtypesSearch_sqlSelectCommand.ExecuteNonQuery();
JobtypesSearch_sqlDataAdapter.Fill(dsJobTypesSearc h1);
dgJobtypesSearch.DataBind();
sqlConnection1.Close();

vacancyText_Panel.Visible = false;
JobTypes_Panel.Visible = true;
}

When I open the aspx file I get the folowing HTML code where the
dropdownlist is:
...
<select name="ddJobtypes" id="ddJobtypes">
<option value="3">Accounting and Audit Classification</option>
<option value="1">Dental Officer</option>
<option value="4">Education Officers</option>
</select><input type="submit" name="jobtypes_btn" value="GO!"
id="jobtypes_btn" />
...

When I click the jobtypes_btn button (after selecting any of the options), it gives me the result for option value 3 and the HTML code turns:

<select name="ddJobtypes" id="ddJobtypes" class="formTxtBox">
<option selected="selected" value="3">Accounting and Audit
Classification</option>
<option value="1">Dental Officer</option>
<option value="4">Education Officers</option>
</select><input type="submit" name="jobtypes_btn" value="GO!"
id="jobtypes_btn" class="formTxtBox" />

What am I doing wrong?

SSP


Nov 17 '05 #3
SSP
Yep, it was a postback problem.

The same code didn't work earlier and it worked the second time around! I
swear asp.net has something against me :-)

Thanks Saravana

SSP

"Saravana [MVP]" <sa******@sct.co.in.nospam> wrote in message
news:OG**************@tk2msftngp13.phx.gbl...
Are you checking for ispostback() before binding your dropdownlist.

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

"SSP" <ss*@dt.com> wrote in message
news:eO*************@TK2MSFTNGP11.phx.gbl...
I have a dropdown list on my page as:

<asp:dropdownlist id=ddJobtypes runat="server" ></asp:dropdownlist>
<asp:button id=jobtypes_btn runat="server" Text="GO!"></asp:button>

This is bound in the codebehind file as:

JobTypesDD_sqlDataAdapter.Fill(dsJobTypesDD1);
ddJobtypes.DataSource = dsJobTypesDD1;
ddJobtypes.DataTextField = "jobClassName";
ddJobtypes.DataValueField = "jobClassID";
ddJobtypes.DataBind();

When I click the button "jobtypes_btn" the following is called:

private void jobtypes_btn_Click(object sender, System.EventArgs e)
{
JobtypesSearch_sqlSelectCommand.Parameters["@jobClass"].Value =
ddJobtypes.SelectedValue.ToString();
sqlConnection1.Open();
JobtypesSearch_sqlSelectCommand.ExecuteNonQuery();
JobtypesSearch_sqlDataAdapter.Fill(dsJobTypesSearc h1);
dgJobtypesSearch.DataBind();
sqlConnection1.Close();

vacancyText_Panel.Visible = false;
JobTypes_Panel.Visible = true;
}

When I open the aspx file I get the folowing HTML code where the
dropdownlist is:
...
<select name="ddJobtypes" id="ddJobtypes">
<option value="3">Accounting and Audit Classification</option>
<option value="1">Dental Officer</option>
<option value="4">Education Officers</option>
</select><input type="submit" name="jobtypes_btn" value="GO!"
id="jobtypes_btn" />
...

When I click the jobtypes_btn button (after selecting any of the options), it gives me the result for option value 3 and the HTML code turns:

<select name="ddJobtypes" id="ddJobtypes" class="formTxtBox">
<option selected="selected" value="3">Accounting and Audit
Classification</option>
<option value="1">Dental Officer</option>
<option value="4">Education Officers</option>
</select><input type="submit" name="jobtypes_btn" value="GO!"
id="jobtypes_btn" class="formTxtBox" />

What am I doing wrong?

SSP


Nov 17 '05 #4

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

Similar topics

0
by: E . | last post by:
I seem to be getting nowhere with this problem here is the situation. I have a webform with a data grid populated with the results of a table that has only 3 fields. Then below that are 1...
4
by: Paul | last post by:
I have a dropdown list box and a button on a web form, the autopost back is false for the dropdown list box and button. When the button is pushed the selection in the dropdownlist box is lost,...
6
by: Jenna Alten | last post by:
I have a datagrid with a template column that contains a dropdown list. I currently fill and display the dropdown list on the page load. This is working correctly. I am NOT using an Edit Column. I...
1
by: Jack | last post by:
Hello, I have a dropdown list on a user control and the AutoPostBack property is set to True. I want to use the SelectedIndexChanged event to populate some text boxes based on what the user...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
1
by: Oleg | last post by:
Hi, I'm having a problem with page caching and therefore reusing dropdown box contents. Scenerio: user1 has security to see list of three items(.aspx populates it with three items only) in...
5
by: jung_h_park | last post by:
From: jung_h_park@yahoo.com Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Dropdown List not retaining its SelectedValue Date: Mon, 26 Jun 2006 21:02:57 -0700 Hello, My...
3
by: er1 | last post by:
Hi all, I have created a double dropdown list. Based on the first list selection, second list populates (this works fine). I have a submit button, which when clicked should run a select query...
6
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.