473,395 Members | 1,670 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,395 software developers and data experts.

Datasets and Textboxes

34
Hi,
I have a dropdown list that I have populated with a dataset.

Expand|Select|Wrap|Line Numbers
  1.     protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         if (!IsPostBack)
  4.         {
  5.             DataService.DataService myData = new DataService.DataService();
  6.             DataSet domainData = myData.GetDomainData();
  7.  
  8.             StatusDropDownList.DataSource = domainData.Tables[0];
  9.  
  10.             StatusDropDownList.DataTextField = "Name";
  11.             StatusDropDownList.DataValueField = "ID";
  12.  
  13.             StatusTextBox.Text = <-- have problem here...
  14.  
  15.             //Bind the data to the control
  16.             StatusDropDownList.DataBind();
  17.  
  18.             //set default selected item
  19.             StatusDropDownList.SelectedIndex = 0;
  20.         }
  21.     }
  22.  
When I load the page I want the "Detail" column in the dataset to be displayed in the text box. So if the drop down list says "down", then the text box would have text that is in the dataset that corresponds to that selection.

I will work out the part about when a user changes that selection, the text will change, but I can't seem to populate the textbox when the page loads.

Thanks,
JLC
Aug 17 '07 #1
2 1052
nateraaaa
663 Expert 512MB
Hi,
I have a dropdown list that I have populated with a dataset.

Expand|Select|Wrap|Line Numbers
  1.     protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         if (!IsPostBack)
  4.         {
  5.             DataService.DataService myData = new DataService.DataService();
  6.             DataSet domainData = myData.GetDomainData();
  7.  
  8.             StatusDropDownList.DataSource = domainData.Tables[0];
  9.  
  10.             StatusDropDownList.DataTextField = "Name";
  11.             StatusDropDownList.DataValueField = "ID";
  12.  
  13.             StatusTextBox.Text = <-- have problem here...
  14.  
  15.             //Bind the data to the control
  16.             StatusDropDownList.DataBind();
  17.  
  18.             //set default selected item
  19.             StatusDropDownList.SelectedIndex = 0;
  20.         }
  21.     }
  22.  
When I load the page I want the "Detail" column in the dataset to be displayed in the text box. So if the drop down list says "down", then the text box would have text that is in the dataset that corresponds to that selection.

I will work out the part about when a user changes that selection, the text will change, but I can't seem to populate the textbox when the page loads.

Thanks,
JLC
Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         if (!IsPostBack)
  4.         {
  5.             DataService.DataService myData = new DataService.DataService();
  6.             DataSet domainData = myData.GetDomainData();
  7.  
  8.             StatusDropDownList.DataSource = domainData.Tables[0];
  9.  
  10.             StatusDropDownList.DataTextField = "Name";
  11.             StatusDropDownList.DataValueField = "ID";            
  12.  
  13.             //Bind the data to the control
  14.             StatusDropDownList.DataBind();
  15.  
  16.             //set default selected item
  17.             StatusDropDownList.SelectedIndex = 0;            
  18.         }
  19.            CREATE A CASE STATEMENT FOR EVERY SELECTED INDEX
  20.              switch(StatusDropDownList.SelectedIndex)
  21.                case: 0
  22.                     StatusTextBox.Text = //Detail column you want to display
  23.                break;
  24.                default:
  25.                     StatusTextBox.Text = "";
  26.                break;
  27.     }
Nathan
Aug 17 '07 #2
JLC
34
So if the list of values in the drop down list is created from the dataset, can't I just pull out the value I want from the dataset to populate the text box instead of creating a switch statement?

does asp:dropdownlist have another place I could store a string (which would come from my dataset) so I could use it in my text box?

Thanks,
Aug 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Phil D | last post by:
Hi all, I am stuck over a few issues and hope some of you can help me out. I'll start with the scenario: I have a form with 2 textboxs and 3 buttons on it. Behind this is a dataset into which...
4
by: Alpha | last post by:
I have a small Window application and through out the different forms I create a different dataset. At the begining I used the Tools to drag and drop the SqlDataAdapter, connection and dataset...
9
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
16
by: Luqman | last post by:
Is it recommended to use datasets in ASP.Net 2.0 / VS.Net 2005 ? Best Regards, Luqman
4
by: Ronald S. Cook | last post by:
I've always used untyped datasets. In a Microsoft course, it walks through creating typed datasets and harps on the benefits. It has you drag all these things around ..wizard, wizard, wizard......
25
by: Penelope Dramas | last post by:
Hello, I'm in a front of very serious .net redesign/rewrite of an old VB6 application. I had been asked to make it .NET 2.0 and would like to ask couple of questions regarding data access as...
0
by: OldStd | last post by:
Updating data using 2 data sets I am having some problems in updating the database using two datasets as suggested by someone. 1. Data is displayed in a data grid from a dataset generated using...
0
by: S.Tedeschi | last post by:
Hi all; as posted some days ago, I'm converting an on-line app; I used to heavily rely on strongly-typed DataSets directly dropped onto pages, and so viewed by code(-behind) as well. In the next...
12
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a...
9
by: gardnern | last post by:
We have X number of data sets, of Y length each. For example... Small, Medium, Large and Red, Green, Blue, Yellow We need to generate a list of all possibilities Small Red
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.