Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 16th, 2008, 04:45 PM
Authorized User
Join Date: Jan 2008
Location: , , .
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default Drop Down Issue


Could someone tell me why i cant set the value of Querystring variable "Month" on the Drop Down DDL_Month. I checked it on debuging mode and it gets the month number in the variable "Month" but it just never set the text on Drop Down (DDL_Month).

Many Thanks

  If Page.IsPostBack = False Then

            Dim iMonth As String = Request.QueryString("Month") ' ID.qs("Month")
            Dim iYear As String = Request.QueryString("Year")
            Dim iname As String = Request.QueryString("Category")

            If iMonth <> "" And iYear <> "" And iname <> "" Then
            End If

            If name <> "" Then
                Dim Category As String = name
                Category = Replace(Category, "-", " ")

                If Request.QueryString("Year") <> "" Then
                    DDL_Year.Text = Request.QueryString("Year")
                End If

                If Request.QueryString("Month") <> "" Then
                    DDL_Month.Text = iMonth
                End If

                Dim dt As DataTable
                Dim totalRecords As Integer

                If Request.QueryString("Month") = "" Then
                    dt = BindGvData(CurrentPageNumber, 6, GetCategoryName(Category), 0, 0, totalRecords)

                    dt = BindGvData(CurrentPageNumber, 6, GetCategoryName(iname), iYear, DDL_Month.SelectedValue, totalRecords)
                End If

                Dim i As Integer = totalRecords
                GVListing.DataSource = dt

                Dim totalpages As Double
                totalpages = totalRecords / 6
                totalpages = System.Math.Ceiling(totalpages)
                totalpages = Double.Parse(totalpages)
                Total.Text = totalpages.ToString
                Current.Text = CurrentPageNumber.ToString

                If CInt(Total.Text) >= 1 Then
                    FirstPage.Enabled = True
                    PreviousPage.Enabled = True
                    NextPage.Enabled = True
                    LastPage.Enabled = True

                    If Current.Text <= 1 Then
                        FirstPage.Enabled = False
                        PreviousPage.Enabled = False
                    End If

                ElseIf Total.Text <= 1 Then
                    FirstPage.Enabled = False
                    PreviousPage.Enabled = False
                    NextPage.Enabled = False
                    LastPage.Enabled = True

                End If
                NewsArchivePanel.Visible = True

                NewsArchivePanel.Visible = False
            End If


        End If

  <asp:DropDownList ID="DDL_Month" runat="server">
                                        <asp:ListItem Text = "January" Value = "1" Selected =True ></asp:ListItem>
                                        <asp:ListItem Text = "February" Value = "2"></asp:ListItem>
                                        <asp:ListItem Text = "March" Value = "3"></asp:ListItem>
                                        <asp:ListItem Text = "April" Value = "4"></asp:ListItem>
                                        <asp:ListItem Text = "May" Value = "5"></asp:ListItem>
                                        <asp:ListItem Text = "June" Value = "6"></asp:ListItem>
                                        <asp:ListItem Text = "July" Value = "7"></asp:ListItem>
                                        <asp:ListItem Text = "August" Value = "8"></asp:ListItem>
                                        <asp:ListItem Text = "September" Value = "9"></asp:ListItem>
                                        <asp:ListItem Text = "October" Value = "10"></asp:ListItem>
                                        <asp:ListItem Text = "November" Value = "11"></asp:ListItem>
                                        <asp:ListItem Text = "December" Value = "12"></asp:ListItem>
Reply With Quote
  #2 (permalink)  
Old March 19th, 2008, 06:29 AM
Authorized User
Join Date: Mar 2008
Location: Ahmedabad, Gujarat, India.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts


if you querystring returning number then you cant set drop down month like this

If Request.QueryString("Month") <> "" Then
                    DDL_Month.Text = iMonth
                End If

you need to use selectedvalue property :

If Request.QueryString("Month") <> "" Then
                    DDL_Month.SelectedValue = iMonth
                End If

hope this will work and help you.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop Down List Control Issue PrinceAli0 ASP.NET 2.0 Basics 0 June 9th, 2006 01:46 PM
Drop down issue(s) Annoyamouse Pro PHP 0 March 31st, 2005 06:00 PM
postback issue with drop downlists emachines ADO.NET 3 March 26th, 2005 01:36 PM
postback issue with drop downlists emachines General .NET 1 January 9th, 2005 09:42 PM

All times are GMT -4. The time now is 03:44 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.