472,784 Members | 993 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

DropDown List Default Selected Item

Hello (again),

I have gotten the dropdown list functionality to work through a few tricks
(probably not the most efficient, but it works) but I am not sure how to set
the default selected value. I have tried setting various values to represent
the default value with little success. Essentially I am looking to have the
first item in the list be the default selected item. I noticed in the
properties for a dtat grid you could set a default selected index
(DataGrid.SelectedIndex =). Is there a similiar property for the Dropdown
list that I am just not seeing?

DropDownList.SelectedIndex = 0 does not seem to work.

Regards,
Kris
Nov 18 '05 #1
5 10717
What does not work about setting the list's selectedindex property?

On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
<kr***************************@hybrid-learning.com> wrote:
Hello (again),

I have gotten the dropdown list functionality to work through a few tricks
(probably not the most efficient, but it works) but I am not sure how to set
the default selected value. I have tried setting various values to represent
the default value with little success. Essentially I am looking to have the
first item in the list be the default selected item. I noticed in the
properties for a dtat grid you could set a default selected index
(DataGrid.SelectedIndex =). Is there a similiar property for the Dropdown
list that I am just not seeing?

DropDownList.SelectedIndex = 0 does not seem to work.

Regards,
Kris


Nov 18 '05 #2
Well, it seems although I set the property as follows:

DropDownList.SelectedIndex = 0

the selected value is not passed. If I try to get the value after setting
this I no return (although I do see the associsted text in the DDList).
However, if I select a different value and then select the initial value it
does retuen the index.

Regards,
Kris

"Dan Brussee" <db******@nc.rr.com> wrote in message
news:m4********************************@4ax.com...
What does not work about setting the list's selectedindex property?

On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
<kr***************************@hybrid-learning.com> wrote:
Hello (again),

I have gotten the dropdown list functionality to work through a few tricks(probably not the most efficient, but it works) but I am not sure how to setthe default selected value. I have tried setting various values to representthe default value with little success. Essentially I am looking to have thefirst item in the list be the default selected item. I noticed in the
properties for a dtat grid you could set a default selected index
(DataGrid.SelectedIndex =). Is there a similiar property for the Dropdown
list that I am just not seeing?

DropDownList.SelectedIndex = 0 does not seem to work.

Regards,
Kris

Nov 18 '05 #3
Just being sure. You mention checking the value. The SelectedValue is
quite different than the SelectedIndex. Setting the SelectedIndex to 0
will select the first item in the dropdown list. It will have both a
Value and Text property as well.
On Sun, 11 Apr 2004 18:29:17 -0400, "Kris Rockwell"
<kr***************************@hybrid-learning.com> wrote:
Well, it seems although I set the property as follows:

DropDownList.SelectedIndex = 0

the selected value is not passed. If I try to get the value after setting
this I no return (although I do see the associsted text in the DDList).
However, if I select a different value and then select the initial value it
does retuen the index.

Regards,
Kris

"Dan Brussee" <db******@nc.rr.com> wrote in message
news:m4********************************@4ax.com.. .
What does not work about setting the list's selectedindex property?

On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
<kr***************************@hybrid-learning.com> wrote:
>Hello (again),
>
>I have gotten the dropdown list functionality to work through a fewtricks >(probably not the most efficient, but it works) but I am not sure how toset >the default selected value. I have tried setting various values torepresent >the default value with little success. Essentially I am looking to havethe >first item in the list be the default selected item. I noticed in the
>properties for a dtat grid you could set a default selected index
>(DataGrid.SelectedIndex =). Is there a similiar property for the Dropdown
>list that I am just not seeing?
>
>DropDownList.SelectedIndex = 0 does not seem to work.
>
>Regards,
>Kris
>


Nov 18 '05 #4
Following what you have said, setting the code as follows should produce the
correct results.

...Omitted Connection, data adapter and Dataset info...

DropDownList.DataBind()
DropDownList.SelectedIndex = 0

In this instance the first item in the list should be selected by default
without any user interaction.

Is that a correct assumption?

Regards,
Kris

"Dan Brussee" <db******@nc.rr.com> wrote in message
news:f8********************************@4ax.com...
Just being sure. You mention checking the value. The SelectedValue is
quite different than the SelectedIndex. Setting the SelectedIndex to 0
will select the first item in the dropdown list. It will have both a
Value and Text property as well.
On Sun, 11 Apr 2004 18:29:17 -0400, "Kris Rockwell"
<kr***************************@hybrid-learning.com> wrote:
Well, it seems although I set the property as follows:

DropDownList.SelectedIndex = 0

the selected value is not passed. If I try to get the value after setting
this I no return (although I do see the associsted text in the DDList).
However, if I select a different value and then select the initial value itdoes retuen the index.

Regards,
Kris

"Dan Brussee" <db******@nc.rr.com> wrote in message
news:m4********************************@4ax.com.. .
What does not work about setting the list's selectedindex property?

On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
<kr***************************@hybrid-learning.com> wrote:

>Hello (again),
>
>I have gotten the dropdown list functionality to work through a few

tricks
>(probably not the most efficient, but it works) but I am not sure how to
set
>the default selected value. I have tried setting various values to

represent
>the default value with little success. Essentially I am looking to
havethe
>first item in the list be the default selected item. I noticed in the
>properties for a dtat grid you could set a default selected index
>(DataGrid.SelectedIndex =). Is there a similiar property for the

Dropdown >list that I am just not seeing?
>
>DropDownList.SelectedIndex = 0 does not seem to work.
>
>Regards,
>Kris
>

Nov 18 '05 #5
Looks right to me.

On Sun, 11 Apr 2004 22:01:58 -0400, "Kris Rockwell"
<kr***************************@hybrid-learning.com> wrote:
Following what you have said, setting the code as follows should produce the
correct results.

..Omitted Connection, data adapter and Dataset info...

DropDownList.DataBind()
DropDownList.SelectedIndex = 0

In this instance the first item in the list should be selected by default
without any user interaction.

Is that a correct assumption?

Regards,
Kris

"Dan Brussee" <db******@nc.rr.com> wrote in message
news:f8********************************@4ax.com.. .
Just being sure. You mention checking the value. The SelectedValue is
quite different than the SelectedIndex. Setting the SelectedIndex to 0
will select the first item in the dropdown list. It will have both a
Value and Text property as well.
On Sun, 11 Apr 2004 18:29:17 -0400, "Kris Rockwell"
<kr***************************@hybrid-learning.com> wrote:
>Well, it seems although I set the property as follows:
>
>DropDownList.SelectedIndex = 0
>
>the selected value is not passed. If I try to get the value after setting
>this I no return (although I do see the associsted text in the DDList).
>However, if I select a different value and then select the initial valueit >does retuen the index.
>
>Regards,
>Kris
>
>"Dan Brussee" <db******@nc.rr.com> wrote in message
>news:m4********************************@4ax.com.. .
>> What does not work about setting the list's selectedindex property?
>>
>> On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
>> <kr***************************@hybrid-learning.com> wrote:
>>
>> >Hello (again),
>> >
>> >I have gotten the dropdown list functionality to work through a few
>tricks
>> >(probably not the most efficient, but it works) but I am not sure howto >set
>> >the default selected value. I have tried setting various values to
>represent
>> >the default value with little success. Essentially I am looking tohave >the
>> >first item in the list be the default selected item. I noticed in the
>> >properties for a dtat grid you could set a default selected index
>> >(DataGrid.SelectedIndex =). Is there a similiar property for theDropdown >> >list that I am just not seeing?
>> >
>> >DropDownList.SelectedIndex = 0 does not seem to work.
>> >
>> >Regards,
>> >Kris
>> >
>>
>


Nov 18 '05 #6

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

Similar topics

6
by: passion_to_be_free | last post by:
This is probably simple, but I can't seem to find it anywhere. I have have some values stored in javascript variables. I have a <select> dropdown list whose options correspond to these values. I...
5
by: Kris Rockwell | last post by:
Hello (again), I have gotten the dropdown list functionality to work through a few tricks (probably not the most efficient, but it works) but I am not sure how to set the default selected value....
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
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...
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...
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...
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...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.