Solved

Dynamic ListView Column

Posted on 2011-03-03
1
745 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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

16 Experts available now in Live!

Get 1:1 Help Now