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

Day drop down list in GridView

I have a GridView linked to an ObjectDataSource, when I am in edit mode I'd
like to display a dropdownList with the name of the days and when i save the
changes I'd like to store 0 for sunday 1 for monday ecc ecc
Do you know how can I do it?
Thanks, Diego.
Nov 19 '05 #1
1 1198
If I understand your question correctly, on the ItemDataBound event you
could do something like this:

If e.Item.ItemType = ListItemType.EditItem Then

'look for the ddlWeekDay dropdown
Dim ddlWeekDay As DropDownList =
CType(e.Item.FindControl("ddlWeekDay"), DropDownList)

'populate the dropdown values
Dim mySortedList As New System.Collections.SortedList
Dim Item As DictionaryEntry

mySortedList("0") = "Sunday"
mySortedList("1") = "Monday"
mySortedList("2") = "Tuesday"
mySortedList("3") = "Wednesday"

For Each Item In mySortedList
Dim newListItem As New ListItem
newListItem.Text = Item.Value
newListItem.Value = Item.Key
ddlWeekDay.Items.Add(newListItem)
Next

'set the current value held in the database
Dim currentWeekDay As String =
DataBinder.Eval(e.Item.DataItem, "WeekDay")
Dim li As ListItem =
ddlWeekDay.Items.FindByValue(currentWeekDay.ToStri ng())
If Not (li Is Nothing) Then
li.Selected = True
End If
Hope this helps.
Kat
*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #2

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

Similar topics

1
by: MasterChief | last post by:
I am using a gridview and having it display what is selected in a drop-down list. How do I set it so the gridview will show all by default. I have added an ALL.. item to the item collection of the...
1
by: Bishop | last post by:
I made a GridView with a Drop Down List using the example here: http://www.orcsweb.com/articles/dotnet_control_templates.aspx It appears to work except that it dosn't actually save the updated...
0
by: ayneekeaw | last post by:
When I click the update button/link at the Gridview to update the data from drop down list into the SQL. The selected value of drop down list change to default value. How can I fix this problem
4
by: Bishop | last post by:
I have a query similar to this: "Select ProductID, ProductName, ProductDescription where MFGID = @MFGID". I use a Drop Down List populated with the MFGID's to populate the @MFGID variable. My...
2
by: CDonlan | last post by:
I'm trying to add a drop down list to a gridview header. The number of columns can change so it has to be done in the code behind (the .cs file). Please help me with this.
2
by: McGeeky | last post by:
Hi. I have a read only GridView. For each row I want to display a drop down list which contains a list of actions the user can select from for that particular row. E.g. "view details". When they...
2
by: pieandpeas | last post by:
Hi, I am using a gridview to show information from a database nameid | name | address1 | postcode | countryid 1 | bob | 24 green street | ga22ac | 2 and a country table
5
by: Mark B | last post by:
I'd like to have a field in a gridview (or standalone on a webpage) that not only drops down each salespersons name but also precedes their name with a blue, red, green or orange dot icon depicting...
3
by: Slickuser | last post by:
Hi, I would like to put a drop down menu in a gridview with the datatype selected from the SQL database. These are the values will show. red orange white green
1
by: slickuser | last post by:
Hi, How can I get the selected value from the drop down menu list inside the GridView command when the user click updated button on that row? Thanks. <asp:BoundField DataField="NAME"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...

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.