Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataBinding ListBox.DataTextField

Reply
Thread Tools

DataBinding ListBox.DataTextField

 
 
=?Utf-8?B?bXVzb3NkZXY=?=
Guest
Posts: n/a
 
      04-03-2006
Hi guys

I have an asp:ListBox on my form, which I'm populating with a DataReader,
using DataSource/DataBind.

The problem is that the main field I want to use for DataTextField,
"Company" in this case, is often blank. How can I get the DataBinding to
go...

"if Company is blank, use ContactName, else use Company"

...is that even possible? Or is there a way I can do this in the SQL somehow?

Hope that makes sense!

Cheers



Dan
 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      04-03-2006
Dan,

You can do it in the select:

select ... case Company when null then ContactName else Company end as
CompanyName...

Eliyahu

"musosdev" <> wrote in message
news:2F0F70F4-0A5F-4B99-B0CD-...
> Hi guys
>
> I have an asp:ListBox on my form, which I'm populating with a DataReader,
> using DataSource/DataBind.
>
> The problem is that the main field I want to use for DataTextField,
> "Company" in this case, is often blank. How can I get the DataBinding to
> go...
>
> "if Company is blank, use ContactName, else use Company"
>
> ..is that even possible? Or is there a way I can do this in the SQL
> somehow?
>
> Hope that makes sense!
>
> Cheers
>
>
>
> Dan



 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      04-04-2006
Hi Dan,

ListBox is a simple databound control which doesn't support itemdatabound
event like repeater or datalist. So if you want to do it in ASP.NET layer,
you can consider programmtically loop through the datareader and populate
the listbox instead of using databinding. Also, for T-SQL layer, you can
have a look at Eliyahu's suggestion and you can also try posting in
SQLServer. programming newsgroup since there're many experiences SQL guys
there.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding expressions are only supported on objects that have a DataBinding event jobs ASP .Net 0 09-25-2007 11:54 PM
Gridview encoding, or how to run commands before gridview's default databinding, or, how do I disable default databinding at all? Sergei Shelukhin ASP .Net 1 11-12-2006 01:43 PM
ComboBox design-time DataBinding setting questions. dbuchanan ASP .Net 3 02-01-2006 12:15 PM
DataGrid Custom Column Error when DataBinding "does not contain a definition for 'DataBinding'" Earl Teigrob ASP .Net Datagrid Control 1 03-01-2004 04:52 AM
is databinding in asp.net read-only? neil m ASP .Net 3 06-27-2003 11:48 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57