Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding Column data in a datagrid template for hyperlink 1

Status
Not open for further replies.

vituja123

Programmer
Jun 16, 2005
110
0
0
US
Hi All,



In my datagrid I want to use a template column as a hyperlink.

But I need to convert a database column value from a date to a single digit representing the day number. So I want to use the WEEKDAY date function as the data is being bound but I keep getting a compulation error where the binding is being done.
<Columns>
<asp:templatecolumn>
<headertemplate>
Day
</headertemplate>
<itemtemplate>
<a href='3-PopupMain.aspx?DOW=<%# DataBinder.Eval(weekday((Container.DataItem, "Date_of_Week"),FirstDayOfWeek.Monday))
%>'>
<b>
<%# DataBinder.Eval(Container.DataItem, "Day")
%>
</b>
</a>
</itemtemplate>
</asp:templatecolumn>
<asp:BoundColumn DataField="day" ReadOnly="True" HeaderText="Day"></asp:BoundColumn>
<asp:BoundColumn DataField="TotalTime" ReadOnly="True" HeaderText="Total Time"></asp:BoundColumn>
<asp:BoundColumn DataField="TotalExpenses" ReadOnly="True" HeaderText="Total out of Pocket"></asp:BoundColumn>
</Columns>
 
How about you try using the ItemDataBound event of the DG? First, don't bind a value to the hyperlink. Then, in the event, gag the "Date_of_week" value and convert it as you need. Then, assign the value to your hyperlink.

Jim
 
That actually was a lot eaiser.

Thanks jim!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top