ListBox and sqldatasource

  • Thread starter Thread starter walanta
  • Start date Start date
W

walanta

Hi,

I have a ListBox that bind to a sql source with managed code?

I know how to print ListBox1.SelectedItem and ListBox1.SelectedValue.
to print two fields from the following select statement.
But how can I print other fields in my select statement? I guess it
should be ListBox1.something...??

Suppose my select statement is like :

"select custid, name1 as firstname, name2 as lastname, address2 as
address from customer where custid=@custid"
 
ListBox is able to bind only to 2 fields from the datasource: one for the
text and another for the value. It has no idea about any other fields. You
can use the selected item to find the row for the item in the datasource and
get other fields from the datasource itself.
 
I'm not sure I understand your second sentence.
Could you give me an quick example or point me to where I can get the
information or example? Thanks!!!
 
Asp.Net renders server control ListBox as certain html element rendered by
the client browser. Datasource and databinding is needed to fill up the
element properties. These properties are the text and the value of the items
that the listbox contains. They are taken from the datasource fields. Other
fields that the datasource contains are not needed for the listbox
functionality. They are not available via the listbox.
 
Back
Top