How to pre-set combo textbox's selectedindex value from querystring passed from another page?

Discussion in 'ASP .Net' started by ABC, Oct 4, 2005.

  1. ABC

    ABC Guest

    How to pre-set combo textbox's selectedindex value from querystring passed
    from another page?

    I pass the querystring to set combo text box (change selectedindex on
    Page_Init).
    Source code as:

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Me.Init
    If Not (Page.IsPostBack) Then
    If Not String.IsNullOrEmpty(Request.QueryString("RptType")) Then
    Dim rptType As String =
    Request.QueryString("RptType").ToString
    Select Case rptType
    Case "Invoice"
    ReportTypeCombo.SelectedIndex = 0
    Session("RptType") = "Invoice"
    Case "P.O."
    ReportTypeCombo.SelectedIndex = 1
    Session("RptType") = "P.O."
    Case "Contract"
    ReportTypeCombo.SelectedIndex = 2
    Session("RptType") = "Contract"
    End Select
    End If
    End If
    End Sub

    When I run it, it don't work. What is my wrong?
    ABC, Oct 4, 2005
    #1
    1. Advertising

  2. ABC

    Jon Guest

    Make sure that code runs AFTER you populate the combo box


    "ABC" <abc.abc.com> wrote in message
    news:O9$...
    > How to pre-set combo textbox's selectedindex value from querystring passed
    > from another page?
    >
    > I pass the querystring to set combo text box (change selectedindex on
    > Page_Init).
    > Source code as:
    >
    > Protected Sub Page_Init(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles Me.Init
    > If Not (Page.IsPostBack) Then
    > If Not String.IsNullOrEmpty(Request.QueryString("RptType"))
    > Then
    > Dim rptType As String =
    > Request.QueryString("RptType").ToString
    > Select Case rptType
    > Case "Invoice"
    > ReportTypeCombo.SelectedIndex = 0
    > Session("RptType") = "Invoice"
    > Case "P.O."
    > ReportTypeCombo.SelectedIndex = 1
    > Session("RptType") = "P.O."
    > Case "Contract"
    > ReportTypeCombo.SelectedIndex = 2
    > Session("RptType") = "Contract"
    > End Select
    > End If
    > End If
    > End Sub
    >
    > When I run it, it don't work. What is my wrong?
    >
    Jon, Oct 4, 2005
    #2
    1. Advertising

  3. ABC

    Praveen Guest

    Hi,
    Chech the same code by moving that code block from Page_Init to
    Page_Load....
    Praveen P.
    Praveen, Oct 4, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Sikorsky
    Replies:
    3
    Views:
    8,616
    clintonG
    May 21, 2005
  2. Mehdi
    Replies:
    6
    Views:
    36,063
    sloan
    Apr 6, 2006
  3. Anand
    Replies:
    2
    Views:
    887
    Anand
    Sep 11, 2003
  4. dthmtlgod

    Fill Combo Box based on another Combo Box

    dthmtlgod, Nov 16, 2005, in forum: ASP General
    Replies:
    1
    Views:
    568
    Bob Barrows [MVP]
    Nov 16, 2005
  5. SM
    Replies:
    2
    Views:
    352
Loading...

Share This Page