Hi all. This is my first post… be gentle :)
I'm not looking for the code to make it work... if you could just point me in the right direction... I am self-taught and really need to learn by doing rather then having it given to me. Thanks all!
I have a WinForm with a single ListBox and several TextBoxes. I have an SQL database in the project. I am currently using a connection string to open and read the data filling a dataTable. I have set my ListBox Source and DisplayMember which are working properly. My ListBox displays LastName, FirstName as it should by combining the LastName and FirstName fields in the commandString.
My issue is how I achieve dataBinding/concurrency without using “drop and drag” binding within Visual Studio?
I have to cycle through the records in the ListBox and have the corresponding TextBoxes display the record information. I understand using the SelectedIndexCh anged event for the listbox but I’m missing the “piece” to make the whole thing work.
Here is the code to open, read and fill listbox: - string connectionString = "Data Source=walsh\\sqlexpress;Database=PPDOne_db;Integrated Security=True;";
-
SqlConnection conn = new SqlConnection(connectionString);
-
string commandString = "SELECT *, NameLast +', ' + NameFirst AS NameFull FROM tblAdvocates ORDER BY NameLast";
-
SqlDataAdapter dataAdapter = new
-
SqlDataAdapter(commandString, conn);
-
DataSet ds = new DataSet();
-
dataAdapter.Fill(ds, "prog");
-
dataTable = ds.Tables["prog"];
-
lbxAdvocates.DataSource = ds.Tables["prog"].DefaultView;
-
lbxAdvocates.DisplayMember = "NameFull";
-
lbxAdvocates.SetSelected(0, true);
-
conn.Close();
Any help would be appreciated!
1 1478 tlhintoq 3,525
Recognized Expert Specialist TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out. Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dtblankenship |
last post by:
Hello everyone,
I know this question has been asked many times in the forums, and after
spending a few days reading, I am still confused as to the answer.
I have a ListBox (lstBox), SqlConnection (sqlConnection),
SqlDataAdapter (daLookupData), SqlDataAdapter (daData), DataSet
(dsLookupData), and DataSet (dsData), all created via the IDE during
design-time. Here is the design of my simple tables: (An example
since I can't post my...
|
by: Kevin Swanson |
last post by:
I'm writing what should be a very simple app against an Oracle database. The
app has a number of user controls, any one of which is loaded into a main
display page using the loadControl method, depending on which menu item a
user selects. Each of these controls follows the same basic pattern: Get a
dataset from the database and then display the results using basic
databinding.
Everything works fine except that I'll occaisionally get an...
|
by: John Bailey |
last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great.
The formview and detailview contorls would automatically layout the controls
for you, the update methods were automatically generated, and the
objectdatasource let you design against a business object through the gui.
Now I am working on my first real web application on 2.0, and I find this
automatic functionality doesn't do much beyond allowing me to generate...
|
by: Nathan Sokalski |
last post by:
I have two databinding expressions (the first & last names from a DB) that I
want to assign to the text property of a Label so that the result is
LASTNAME,FIRSTNAME. At the moment, I have the following which I know works
when I use it by itself:
text='<%# DataBinder.Eval(Container,"DataItem.membernames.lname") %>'
What I need to do is somehow concatenate this databinding expression, a
comma, and another databinding expression for the...
|
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 answered...
In 1.1 we always did our own myDataAdapter.fills and we liked that control
for lots of good reasons. Now the new DataSource (or is it a
TableAdapter:Dataset) automatically fills the Gridview. How can we control
that fill?
In a...
| |
by: Mark R. Dawson |
last post by:
Hi all,
I may be missing something with how databinding works but I have bound a
datasource to a control and everything is great, the control updates to
reflect the state of my datasource when I update the datasource - awesome,
but I have an issue with updating from a different thread.
Here is my datasource, a person class that raises the PropertyChanged event:
class Person : INotifyPropertyChanged
{
|
by: Nathan Sokalski |
last post by:
I have a very simple UserControl which contains an Image and a Label, which
I use to display an image with a caption. I am using this control inside a
DataList, setting the two Public variables using attributes in the *.aspx
page. Everything displays great for the initial load, but whenever I try to
add or delete an item (I have controls to do this on the page), it does not
seem to be recieving any values for the public variables. Here is...
|
by: Dirk |
last post by:
Hello,
I have a problem to use databinding with my business layer classes. My
data class does not have simple properties (string, int or datetime),
instead, all my properties are objects of the generic type Field<T>
(see sample code).
public class Employee
{
public Field<stringForename
|
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= |
last post by:
Hello to all,
I want to know if DataBinding in asp.net 2,0 is better than to fill up the
values of the controls of the following form:
this.miControlTextBox.Text = valorParaControlTextbox;
Performance with databinding is good in asp.net 2.0 ? Would you prefer:
databinding or set value to Text property of control ?
|
by: nelsonbrodyk |
last post by:
Hey All,
I have been able to set up a databinding to a property with the following code:
<TextBox x:Name="txtTextBox" Text="{Binding Path=NameFirst, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
and in the code:
profile = context.NewProfile();
profile.NameFirst = "My Name";
txtTextBox.DataContext = profile;
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |