Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dynamic ListView Column

Posted on 2011-03-03
1
Medium Priority
?
791 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 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