11 Replies - 4314 Views - Last Post: 08 June 2010 - 06:32 AM

#1 bravo659   User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 181
  • Joined: 18-May 08

RadiobuttonList

Posted 01 June 2010 - 07:51 PM

I have two web forms to display. The default web page I have a textbox, button, listbox for incidents and radiobuttonlist and a submit button.
I am having trouble displaying contents of the rediobuttonlist to the label in the second page. This is my code.

How can I display the contents of the Default.aspx to the label of the SurveyCompletePage.aspx. At least I know how to retrieve the page. :)
Can you please help?

Default.aspx
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.DBNull


Partial Class SurveyPage
    Inherits System.Web.UI.Page

    Private selectedIncident As Incident
 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        txtCustomerID.Focus()
        
    End Sub

    Protected Sub btnGetIncidents_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetIncidents.Click
        Me.CustomerIncidentDisplay()

        rbResponse.Enabled = True
        rbEfficency.Enabled = True
        rbResolution.Enabled = True
        rbContact.Enabled = True
        cbContact.Enabled = True
        txtComment.Enabled = True


    End Sub

    
    Public Sub CustomerIncidentDisplay()
        'Set the display for the listbox
        'Set the datasource
        Dim rows As DataView = CType(Me.AccessDataSource1.Select(New DataSourceSelectArguments()), DataView)
        If (Not rows Is Nothing) AndAlso (rows.Count >= 1) Then

            For i As Integer = 0 To rows.Count - 1
                If (rows(i)("CustomerID")) = txtCustomerID.Text Then


                    Dim myIncident As String = "Incident for " + (rows(i)("ProductCode") + " closed on " + (rows(i)("DateClosed")) + " " + (rows(i)("Title")))

                    Me.lstIncidents.Items.Add(myIncident)
                End If

            Next i
        End If
    End Sub

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        'txtComment.Text = ("You Selected for Response:  " & rbResponse.SelectedItem.Text & _
        '                  " " & "Efficiency:  " & rbEfficency.SelectedItem.Text & _
        '                  " " & "Resolution:  " & rbResolution.SelectedItem.Text)

        Server.Transfer("SurveyCompletePage.aspx")
    End Sub

SurveyCompletePage.aspx

Partial Class SurveyCompletePage
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim rbResponse As RadioButtonList
        Dim rbEfficency As RadioButtonList
        Dim rbResolution As RadioButtonList

        lblComplete.Text = ("You Selected for Response:  " & rbResponse.SelectedItem.Text & _
                         " " & "Efficiency:  " & rbEfficency.SelectedItem.Text & _
                          " " & "Resolution:  " & rbResolution.SelectedItem.Text)
    End Sub

End Class




Main concentration is on the radiobuttonlist and the display on the SurveyCompletePage.aspx

This post has been edited by bravo659: 01 June 2010 - 07:58 PM


Is This A Good Question/Topic? 0
  • +

Replies To: RadiobuttonList

#2 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: RadiobuttonList

Posted 03 June 2010 - 01:36 PM

Have you considered using Session to pass the information between pages?
If both pages (or more) require access to the information then this is a good place to store the data.
Was This Post Helpful? 1
  • +
  • -

#3 bravo659   User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 181
  • Joined: 18-May 08

Re: RadiobuttonList

Posted 03 June 2010 - 04:57 PM

View PostFrinavale, on 03 June 2010 - 12:36 PM, said:

Have you considered using Session to pass the information between pages?
If both pages (or more) require access to the information then this is a good place to store the data.


Ah yes, I forgot all about the Session state that gather information then transfer to the next web page. Ok I will use that thanks. This should fill the label because by default is multilined right? thanks again.
Was This Post Helpful? 0
  • +
  • -

#4 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: RadiobuttonList

Posted 04 June 2010 - 06:46 AM

I'm not exactly sure what you're trying to display on the second page.
You can display it in whatever control you want to display it in :)
If the user has to be able to interact with this data then it's probably not a good idea to use a Label...but if the user is supposed to just see the data then a Label is a good choice.

I typically bind my RadioButtonList's to a data source and if I want to use that data source on multiple pages I store it in Session (or sometimes in Cache if it can exist for longer than the user's Session time). That way I can use the same data throughout the website...

-Frinny
Was This Post Helpful? 1
  • +
  • -

#5 bravo659   User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 181
  • Joined: 18-May 08

Re: RadiobuttonList

Posted 04 June 2010 - 09:36 AM

What this application is about is incidents. When a user enters a customer id in the textbox the the data source appear in the listbox. The user highlight an incident and reads the radiobutton clicks on the appropriate button. Additional comments if any and the contact checkbox radiobutton either email or phone then click on submit and the data from the radiobuttonlist and the additional comment should appear in the same label.
Was This Post Helpful? 0
  • +
  • -

#6 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: RadiobuttonList

Posted 04 June 2010 - 09:47 AM

Oh so what you're looking to do is not display the entire RadioButtonList's datasource, you just want to display the information about the selected radio button.

I just went over your code again (sorry I had you mixed up with someone else I'm helping)...

If you continue to use Server.Transfer, in your SurveyCompletePage...comment out the following:

Dim rbResponse As RadioButtonList
Dim rbEfficency As RadioButtonList
Dim rbResolution As RadioButtonList


What you are doing is creating new RadioButtonLists but with Server.Transfer all of the controls on the page that you transferred from should be available (that's the weird thing about Server.Transfer). Since you are creating new controls for existing controls you're running into problems (the new controls don't have the information that the existing ones do...and really the new controls should not be even used)

I don't recommend Server.Transfer unless you are intimate with it.
I recommend that you use Response.Redirect and store the Selected Value in Session for the next page to access. Unless you know what you're doing with Server.Transfer :)
Was This Post Helpful? 1
  • +
  • -

#7 Guest_Desi Bravo*


Reputation:

Re: RadiobuttonList

Posted 04 June 2010 - 05:28 PM

View PostFrinavale, on 04 June 2010 - 08:47 AM, said:

Oh so what you're looking to do is not display the entire RadioButtonList's datasource, you just want to display the information about the selected radio button.

I just went over your code again (sorry I had you mixed up with someone else I'm helping)...

If you continue to use Server.Transfer, in your SurveyCompletePage...comment out the following:

Dim rbResponse As RadioButtonList
Dim rbEfficency As RadioButtonList
Dim rbResolution As RadioButtonList


What you are doing is creating new RadioButtonLists but with Server.Transfer all of the controls on the page that you transferred from should be available (that's the weird thing about Server.Transfer). Since you are creating new controls for existing controls you're running into problems (the new controls don't have the information that the existing ones do...and really the new controls should not be even used)

I don't recommend Server.Transfer unless you are intimate with it.
I recommend that you use Response.Redirect and store the Selected Value in Session for the next page to access. Unless you know what you're doing with Server.Transfer :)


Ok cool, then I'll use the Respone.Redirect i get em confused with the Server.Transfer. So whenever i have data from controls to be view in the nex folowing web page then use Response.Redirect plus the controls to be viewed. Hey Thanks. :)
Was This Post Helpful? 0

#8 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: RadiobuttonList

Posted 07 June 2010 - 06:22 AM

You should probably do some research on the Response.Redirect and Server.Transfer methods. Both of them are very different. I have a feeling that you don't quite understand what I'm getting at :)

-Frinny
Was This Post Helpful? 0
  • +
  • -

#9 bravo659   User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 181
  • Joined: 18-May 08

Re: RadiobuttonList

Posted 07 June 2010 - 07:26 AM

View PostFrinavale, on 07 June 2010 - 05:22 AM, said:

You should probably do some research on the Response.Redirect and Server.Transfer methods. Both of them are very different. I have a feeling that you don't quite understand what I'm getting at :)

-Frinny


Nah, I understood what you was saying. Session are also used to point data to another page's label. If i click on a radiobutton then click submit what the data on the radiobutton should display in a label or a read-only textbox on the confirmationPage.aspx. So I use Server.Transfer to go to the confirmationPage.aspx and the session to display the radiobutton's data. I done the same thing in C#. VB is a little different but the same concept. If i want to return to the main page then i use Response.Redirect. The difference between Response.Redirect and Server.Transfer are very simple to understand.

:) Desi Bravo

This post has been edited by bravo659: 07 June 2010 - 07:29 AM

Was This Post Helpful? 0
  • +
  • -

#10 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: RadiobuttonList

Posted 07 June 2010 - 08:23 AM

The important point that I think you're not getting is that with Server.Transfer that the the form variables from the first page are available in your second page when you use the Server.Transfer method.

Well actually, Server.Transfer method has a parameter called "preserveForm" and if you set this to True, using a statement such as Server.Transfer("AnotherPage.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to.

So, in theory, you don't need to use Session if you use Server.Transfer...
In fact, a couple of years ago when I was attempting to use Server.Transfer, I ran into a whole bunch of issues with the fact that form variables were being preserved in this manner. Strange things can happen to memory and you have to be careful with it.

That is why I recommended that you use Response.Redirect instead of Server.Transfer. With Response.Redirect you will need to use something like Session (or cookies or whatever you want to...but Session's easiest) to transfer the information between pages because all of the form variables are not available on the next page with Response.Redirect.

Hope I'm making sense to you,

-Frinny
Was This Post Helpful? 1
  • +
  • -

#11 bravo659   User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 181
  • Joined: 18-May 08

Re: RadiobuttonList

Posted 07 June 2010 - 07:20 PM

View PostFrinavale, on 07 June 2010 - 07:23 AM, said:

The important point that I think you're not getting is that with Server.Transfer that the the form variables from the first page are available in your second page when you use the Server.Transfer method.

Well actually, Server.Transfer method has a parameter called "preserveForm" and if you set this to True, using a statement such as Server.Transfer("AnotherPage.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to.

So, in theory, you don't need to use Session if you use Server.Transfer...
In fact, a couple of years ago when I was attempting to use Server.Transfer, I ran into a whole bunch of issues with the fact that form variables were being preserved in this manner. Strange things can happen to memory and you have to be careful with it.

That is why I recommended that you use Response.Redirect instead of Server.Transfer. With Response.Redirect you will need to use something like Session (or cookies or whatever you want to...but Session's easiest) to transfer the information between pages because all of the form variables are not available on the next page with Response.Redirect.

Hope I'm making sense to you,

-Frinny


Ok I am now understanding what you're saying. That is a nice feature preseverForm to use. I am fairly new to ASP.Net as you know. That is why I am here looking for help. You do make a lot of sense. You had the experience that i am now trying to learn. LOL. Yes it can also be confusing to use and learn the concept of both. I currently was using the Response.Redirect to return to the main page from a secondary page.
Such as Default.aspx from SurveyConfirmationPage.aspx. I used it as
Response.Redirect("Default.aspx") and to go to the SurveyConfirmationPage is Server.Transfer("SurveyConfirmationPage.aspx").
This is the way I am being taught how to use either one. But can't figure out how to get the radiobuttons for work from the default page to the surveyconfirmation pages. I done this in C# but don't know how to convert it to VB. This is the C# code.


Default.aspx

protected void btnSubmit_Click(object sender, EventArgs e)
    {
          //use the session  variable to include objects or text to another page
            // user enters a name and email and appearin the labels of the confirmation page
            Session["name"] = txtName.Text;
            Session["email"] = txtEmail.Text;
            //this open the other form or web page
            Server.Transfer("Confirmation_Page.aspx");        
    }



Confimation_Page.aspx

 protected void Page_Load(object sender, EventArgs e)
    {
        //declare variables that will show outcome from first web page
        //Session from the main web page
        string emailString = Session["email"].ToString();
        string nameString = Session["name"].ToString();

        if (emailString != string.Empty)
        {
            //Session["email"] = txtEmail.Text from Default.aspx
            lblEmail.Text = emailString;
        }

        if (nameString != string.Empty)
        {
            //contents of the txtName.Text from Default.aspx
            //in following label Session["name"] = txtName.Text;
            lblMessage.Text = "Welcome" + nameString;
        }



This is all done in C# so I figured using the same code and convert it to VB it would work or something similar but in VB but didn't get it to work.

This post has been edited by bravo659: 07 June 2010 - 07:22 PM

Was This Post Helpful? 0
  • +
  • -

#12 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: RadiobuttonList

Posted 08 June 2010 - 06:32 AM

Well since you're having problems with the VB.NET code why don't you post what you have so that we can go from there :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1