Solved

Dynamic ListView Column

Posted on 2011-03-03
1
754 Views
Last Modified: 2012-06-27
Hello, I've got a standard ListView control setup that displays data from a SQL database based on a query that I provide to it.

Along with the columns I indicated in the creation of the ListView control, I need to create 1 dynamic column that holds data from one of two other columns in the ListView.  Here is the logic:

My custom column will be called Column3.  If something exists in the first column, add it to the Column3 ELSE if something exists in the second column add it to Column3.

The data for all of the columns except this dynamic column (Column3) would be drawn directly from the database.

Code examples would be great.

Also, would it be possible to add such a dynamic column to a GridView?

I'm using ASP.NET (C#) 3.5 Framework.

Thank you in advance.
0
Comment
Question by:karlhsc
1 Comment
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 500 total points
ID: 35032827
Hi,

You can do it right from your SQL query, something like this

SELECT Field1, Field2,
CASE
     When Field1 Is Not Null THEN Field1
     When Field2 Is Not Null THEN Field2
     Else ' '
END As Field3
FROM YourTable
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now