Question: a) How to populate the data in ListBox from the database.b) How to display the relevant Details in the Textboxes for selected item.
Solution: Solution a)
To display the data in the Listbox from the Database is simple binding. (In our sample we are populating the ListBox with the EmployeeId's.)
Step 1:
SqlConnection mycn;SqlDataAdapter myda;DataSet ds;String strConn;
Solution b)
To display the details for the ListItem Selected in the Textboxes. (i.e Show Details of the EmployeeID selected)
This can be done by designing a page with n number of Textboxes based on the columns in the Database Table. Or the other solution is to create these Textboxes dynamically.
Lets take a look on how to create the Controls Dynamically. The sample shows the data from Employees Table (Northwind DataBase).
This Table has Columns having DataType as string, DateTime, Byte[]. So as we go through the process of dynamically adding the controls we'll also see how to handle these DataTypes and display the data accordingly.
We'll drag and drop PlaceHolder ( One to display the data in the Text Format and other to display the image i.e to handle the System.Byte[] DataType)
Step 2:
private
<
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: