Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

Day drop down list in GridView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Diego - 15 Jul 2005 15:03 GMT
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.
KatB - 15 Jul 2005 17:13 GMT
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.ToString())
           If Not (li Is Nothing) Then
               li.Selected = True
           End If

Hope this helps.
Kat

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.