VB.NET - Concatenating fields in a grid

Hi,

I need to combine three fields into one column.

I made a grid in VB.NET that displays data from 3 fields in my database.  Here is a screenshot of how it comes out:
http://danallen.com/pics/grid.JPG


CODE PRODUCING THE GRID
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataSourceID="ObjectDataSource_ThinkVTCalendarItems" DataKeyNames="ID,UserID,ModuleId" CellPadding="4" CellSpacing="1" EnableViewState="False">
<Columns>
<asp:BoundField DataField="UserID" HeaderText="UserID" SortExpression="UserID" Visible="False" />
<asp:BoundField DataField="ModuleId" HeaderText="ModuleId" SortExpression="ModuleId" Visible="False" />
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" Visible="False" />
<asp:HyperLinkField DataTextField="calendarLINK" DataNavigateUrlFields="calendarURL" HeaderText="Event"  />
<asp:BoundField DataField="calendarLOC" HeaderText="Location" SortExpression="calendarLOC"  />
<asp:BoundField DataField="calendarDisplayDATE" HeaderText="Date" SortExpression="calendarDisplayDATE"  />
</Columns>


PROBLEM:
I need to make this grid have one column, filled with the three fields from grid I have now.  The column of values should come out like this:

6th Annual Workplace Safety Conference - Dusquene February 13, 2008
Forklift Operator Safety Training - White Plains February 15, 2008
etc...

Important:  The event name, before the dash, needs to be a link.  The dash and the location are plain text.  The dates need to be bold.  The full string needs to be in one column, not 3.

QUESTION
How do I change the code above to get the single column with the combined/concatenated string I need?

As always, any assistance in answering this question will be appreciated immensely.

Best regards,
Danimal
LVL 1
DanimalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

QPRCommented:
Not sure which 3 columns we are dealing with but....
turn column 1 into a template field and remove the other 2.
Switch to code view and build your column like....

eval("column1") & "-" & eval("column") etc etc
Another way (but ugly) would be to do it in your select (if the datasource is a query)
select column1 + '<strong>' + column2 + '- </strong>' as SomeColumnName
0
DanimalAuthor Commented:
QPR, thank you for answering quickly.

I understand how to do this with SQL, but I would rather do it the first way you suggested.  Unfortunately, I am still pretty new with .NET, so my confusion is very basic.

The columns I am dealing with are
calendarLINK + calendarURL
calendarLOC
calendarDisplayDATE

I am working only in code view.
How do I get the three fields to evaluate the way you are saying in one column? In classic ASP, it would look something like this:

Foreach returned record:
<a href="<%=calendarURL%>">calendarLINK</a>-<%=calendarLOC%> <b><%=calendarDisplayDATE%></b>
0
NazoUKCommented:
Given your criteria above I think this should work:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataSourceID="ObjectDataSource_ThinkVTCalendarItems" DataKeyNames="ID,UserID,ModuleId" CellPadding="4" CellSpacing="1" EnableViewState="False">
<Columns>
<asp:BoundField DataField="UserID" HeaderText="UserID" SortExpression="UserID" Visible="False" />
<asp:BoundField DataField="ModuleId" HeaderText="ModuleId" SortExpression="ModuleId" Visible="False" />
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" Visible="False" />
<asp:TemplateField HeaderText="Event">
    <ItemTemplate>
        <a href='<%#Eval("calendarURL") %>'><%#Eval("calendarLINK") %></a>
         - <%#Eval("calendarLOC") %> <b><%#Eval("calendarDisplayDATE") %></b>
    </ItemTemplate>
</asp:TemplateField>
</Columns>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

DanimalAuthor Commented:
NazoUK,

Thank you!  That code snippet looks exactly like what I need.

This probably gets into something slightly broader, but when I ran the code you provided, I got this error:
error BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types. ---> System.Web.HttpCompileException
0
QPRCommented:
remove the three bound columns from your code and instead add a template column

<asp:templatefield>
<itemtemplate>
<a href=<%# eval("calendarURL") %> calendarLink</a>-<%#eval("calendarLOC")%><b><%#eval("calendarDisplayDATE")%></b>
</itemtemplate>
</asp:templatefield>
0
NazoUKCommented:
Somewhere in your code-behind you have a sub routine that is trying to handle an event for a control that it can't find. Look for a sub routine that has handles after it and make sure there is a control that matches the name.

Eg. Sub Button1_click(sender as object, e as eventargs) handles button1.click

in this case there should be a button called button1 on the page.
0
DanimalAuthor Commented:
Thank you very much!
0
DanimalAuthor Commented:
NazoUK, I made a mistake applying the code you provided.  When I tried again, it worked.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.