Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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

 Hi

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


Code:
  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
                Response.Write("Hello")
            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)
                Else

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

                Dim i As Integer = totalRecords
                GVListing.DataSource = dt
                GVListing.DataBind()

                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

            Else
                NewsArchivePanel.Visible = False
            End If
        Else

            UpdateURL()

        End If

Code:
  <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>
                                </asp:DropDownList>
  #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
Default

hi,

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.





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





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