Simple solution using
VB and SQL Server
in .aspx
Code:
<asp:SqlDataSourceID="SqlDataSource1"runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"SelectCommand="SELECT [DriverID], DriverFirstname + ' ' + DriverLastName as DriverName FROM [Driver]">
</asp:SqlDataSource>
<asp:DropDownListID="DriverDropDownList"runat="server"AutoPostBack="True"DataSourceID="SqlDataSource1"DataTextField="DriverName"DataValueField="DriverID">
</asp:DropDownList>
<br/>
<asp:LabelID="DriverIDLabel"runat="server"Text="Label"></asp:Label>
<br/>
In Code behind .aspx.
vb
Code:
ProtectedSub DriverDropDownList_SelectedIndexChanged(ByVal sender AsObject, ByVal e As System.EventArgs) Handles DriverDropDownList.SelectedIndexChanged
DriverIDLabel.Text = DriverDropDownList.SelectedValue
EndSub
This displays DriverFirstName and DriverLastName
When changed then DriverIDLabel displays the DriverID
To convert to C# try
http://www.developerfusion.com/tools/
I rarely use XML as a datasource so can't really help you with this.
If you programatically load the data then using for each line of date
Code:
DriverDropDownList.Items.Add(New ListItem(DriverFirstname & " " & DriverLastName, DriverID))
You will have a new item added to the dropdown list.
Finally you may want to add
Code:
DriverDropDownList.Items.Add("Select Driver")
Before programmatically filling your drop down list.