Solved

Dynamic ListView Column

Posted on 2011-03-03
1
790 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

626 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