473,386 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Listbox problem?

I have problems with listboxes in the webform2.cs, the textboxes are
working well when I do a click on next.
I am missing something. It works with the textboxes.
Here is the file:
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Text;
using System.Xml;
using System.Data.SqlClient;
using System.Globalization;
using System.Text.RegularExpressions;
namespace CuprykWeb
{
/// <summary>
/// Summary description for WebForm2.
/// </summary>
public class WebForm2 : System.Web.UI.Page
{

// Declare field texbox names
protected System.Web.UI.HtmlControls.HtmlInputImage InputImage4;
protected System.Web.UI.HtmlControls.HtmlInputImage InputImage5;
protected System.Web.UI.WebControls.ListBox txtTitle;
protected System.Web.UI.WebControls.TextBox txtFirstName;
protected System.Web.UI.WebControls.TextBox txtLastName;
protected System.Web.UI.WebControls.ListBox txtGender;
protected System.Web.UI.WebControls.ListBox txtSecretWordType;
protected System.Web.UI.WebControls.TextBox txtSecretWord;
protected System.Web.UI.WebControls.TextBox txtCity;
protected System.Web.UI.WebControls.ListBox txtStateProvince;
protected System.Web.UI.WebControls.ListBox txtCountry;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

// Create a new DataSet for Title
//***********************************************
DataSet myDataSetTitle = new DataSet();
// Read XML file and populate tables

myDataSetTitle.ReadXml(Server.MapPath("GeneralInfo rmation/titles.xml"));
// Data bind ListBox the shortcut way
txtTitle.DataSource =
myDataSetTitle.Tables["title"].DefaultView;
txtTitle.DataBind();
// Create a new DataSet for Gender
//***********************************************
DataSet myDataSetGender = new DataSet();
// Read XML file and populate tables

myDataSetGender.ReadXml(Server.MapPath("GeneralInf ormation/genders.xml")
);
// Data bind ListBox the shortcut way
txtGender.DataSource =
myDataSetGender.Tables["gender"].DefaultView;
txtGender.DataBind();
// Create a new DataSet for SecretWordType
//***********************************************
DataSet myDataSetSecretWordType = new DataSet();
// Read XML file and populate tables

myDataSetSecretWordType.ReadXml(Server.MapPath("Ge neralInformation/Secre
tWordTypes.xml"));
// Data bind ListBox the shortcut way
txtSecretWordType.DataSource =
myDataSetSecretWordType.Tables["secretwordtype"].DefaultView;
txtSecretWordType.DataBind();
// Create a new DataSet for States/Provinces
//***********************************************
DataSet myDataSetStateProvince = new DataSet();
// Read XML file and populate tables

myDataSetStateProvince.ReadXml(Server.MapPath("Gen eralInformation/statep
rovinces.xml"));
// Data bind ListBox the shortcut way
txtStateProvince.DataSource =
myDataSetStateProvince.Tables["stateprovince"].DefaultView;
txtStateProvince.DataBind();
// Create a new DataSet for Countries
//***********************************************
DataSet myDataSetCountry = new DataSet();
// Read XML file and populate tables

myDataSetCountry.ReadXml(Server.MapPath("GeneralIn formation/countries.xm
l"));
// Data bind ListBox the shortcut way
txtCountry.DataSource =
myDataSetCountry.Tables["country"].DefaultView;
txtCountry.DataBind();

// Proccess values from Form1 and store them
if (!IsPostBack)
// Evals true first time browser hits the page
{

if (!(Session["webform2_txtTitle"] == null))
{ txtTitle.SelectedItem.Text =
Session["webform2_txtTitle"].ToString(); }
if (!(Session["webform2_txtFirstName"] == null))
{ txtFirstName.Text =
Session["webform2_txtFirstName"].ToString(); }
if (!(Session["webform2_txtLastName"] == null))
{ txtLastName.Text = Session["webform2_txtLastName"].ToString();
}
if (!(Session["webform2_txtGender"] == null))
{ txtGender.SelectedItem.Text =
Session["webform2_txtGender"].ToString(); };
if (!(Session["webform2_txtSecretWordType"] == null))
{ txtSecretWordType.SelectedItem.Text =
Session["webform2_txtSecretWordType"].ToString(); };
if (!(Session["webform2_txtSecretWord"] == null))
{ txtSecretWord.Text =
Session["webform2_txtSecretWord"].ToString(); };
if (!(Session["webform2_txtCity"] == null))
{ txtCity.Text = Session["webform2_txtCity"].ToString(); };
if (!(Session["webform2_txtStateProvince"] ==
null))
{ txtStateProvince.SelectedItem.Text =
Session["webform2_txtStateProvince"].ToString(); };
if (!(Session["webform2_txtCountry"] == null))
{ txtCountry.SelectedItem.Text =
Session["webform2_txtCountry"].ToString(); };

}

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.InputImage4.ServerClick += new
System.Web.UI.ImageClickEventHandler(this.InputIma ge4_Previous);
this.InputImage5.ServerClick += new
System.Web.UI.ImageClickEventHandler(this.InputIma ge5_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

public void InputImage4_Previous(object sender,
System.Web.UI.ImageClickEventArgs e)
{
Server.Transfer("webform1.aspx", true);
}

public void InputImage5_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
Response.Write ("Enter InputImage5_Click");

// Session["webform2_txtTitle"] = txtTitle.SelectedItem.Text;

Session["webform2_txtFirstName"] = txtFirstName.Text;

Session["webform2_txtLastName"] = txtLastName.Text;

// Session["webform2_txtGender"] = txtGender.SelectedItem.Text;

// Session["webform2_txtSecretWordType"] =
txtSecretWordType.SelectedItem.Text;

Session["webform2_txtSecretWord"] = txtSecretWord.Text;

Session["webform2_txtCity"] = txtCity.Text;

// Session["webform2_txtStateProvince"] =
txtStateProvince.SelectedItem.Text;

// Session["webform2_txtCountry"] = txtCountry.SelectedItem.Text;

Server.Transfer("webform3.aspx", true);

Response.Write ("Going to next page.");
}
}
}
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
2 2096
Hi Mathieu,

|| I have problems with listboxes in the webform2.cs, the
|| textboxes are working well when I do a click on next.
|| I am missing something. It works with the textboxes.
|| Here is the file:

We're missing something too, I'm afraid. - Any clue as to what you're asking.

That's a lot of code you've given. Can you say anything specific about what the problem is. Anything about what you suspect is
wrong, etc, etc.

Simply saying that there's an error somewhere and giving a whole load of code is just making it harder to get a solution. You'll
need to find someone with the time and patience to examine all your code in detail. I have enough time to tell you this but not
enough to look at the code!

Sorry.

Regards,
Fergus
Nov 15 '05 #2

Given the following:
protected System.Web.UI.WebControls.DataList txtCountry;

How do I store the value in a session variable?

For example:
I am not sure with datalist.
Session["webform2_txtCountry"] = txtCountry.SelectedItem.Text;

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brian | last post by:
Hi, All, I'm using MS.net 2003 and using a windows.forms.listbox control for my window application but I don't know why the Horizontal Scrollbar could NOT be shown even if I set...
5
by: Bill | last post by:
I have have two list boxes. One is a listing of all possible variables. We'll call this listbox A. The other is a listing of all the selected variables. We'll call this listbox B. If a person...
2
by: Simon P | last post by:
Hello group, I'm in desperate need of help. Here goes : I have the following tables : CONTACTS (ContactID, FirstName, LastName, Company, etc.), SHOWS (ShowID, ShowDescription) and SHOWDETAILS...
1
by: Josema | last post by:
Hi to all, I have a class (persons) that derives from collection base: and another class (person) with this properties: -ID -Name When i have complete filled the object Persons with all...
1
by: MrNobody | last post by:
Hi, I'm doing something where I add custom objects to a ListBox which have aToString() method overriden so it displays what I want. When adding instances of these custom objects to the ListBox I...
1
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the...
4
by: Ron | last post by:
I've got a listbox that holds a list of groups. Users can select a group, hit the remove button and the group should be removed from the listbox. The only problem is that no matter which group you...
8
by: nirdeshonline | last post by:
Hi, I have added a simple listbox in windows form under c# 2.0. It contains a collection of approx 10 strings as list items. Now when i resize the form whole listbox flickers. Please tell me...
9
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback)....
15
by: Doogie | last post by:
I have a .net app that a user currently enters a number in a text box, hits a button and a data call is executed. She wants the ability to enter in multiple numbers (up to 100). So to make...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.