dynamically changing binded data at runtime

M

magister

Hi,

I got a query like this

select longTitle, startDate, endDate, eventId, eventUrl from events

I got a datagrid like this

<asp:datagrid id="DataGrid1" runat="server" enableviewstate="False"
autogeneratecolumns="False" useaccessibleheader="True">
<columns>
<asp:templatecolumn>
<itemtemplate>
<table border="0">
<tr>
<td align="right"><a href="eventdetail.aspx?eid=<%#
DataBinder.Eval(Container.DataItem, "eventId") %>"><%#
DataBinder.Eval(Container.DataItem, "longTitle") %></a></td>
</tr>
<tr>
<td align="right"><%# DataBinder.Eval(Container.DataItem, "startDate")
%></td>
</tr>
<tr>
<td align="right"><a href="eventreg.aspx?eid=<%#
DataBinder.Eval(Container.DataItem, "eventId") %>">Register for this
event</a></td>
</tr>
</table>
</itemtemplate>
</asp:templatecolumn>
</columns>
</asp:datagrid>

I want to change the URL of the first link to eventUrl if it is not
null....

How can I do this???

With private void DataGrid1_ItemDataBound I can't find my way into
this type of DataGrid
only 1 column with a table in it....???

With a method call in the actual DataGrid itself
<a href="<%# WhichLink(DataBinder.Eval(Container.DataItem,
"eventId"),DataBinder.Eval(Container.DataItem, "eventUrl") )
%>"><%#eventNAme %> etc....

I get funny error about types in the code behind....

Suggestions c-sharp like if poss....thanks


m@gs
 
M

Michael Tkachev

Hi,

It's an easy.
<a href='(http:// + DataBinder.Eval(Container.DataItem,
"eventUrl").Equals(DBNull.Value))?"Url_1":"Url_1"'>Test</a>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top