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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sript in a DataGrid

Status
Not open for further replies.

meltingpot

Technical User
May 11, 2004
118
GB
My first go at .NET ..

Im building a datagrid to display fields in a database. One of the columsneeds to have this code running in it - not sure how to do it. The script works fine in classic ASP.

Example:Cut out from main script
<asp:TemplateColumn HeaderText="Warning"
Visible="True">
<ItemTemplate>
<%
Dim strBoat, iElapsed
strBoat = boats("HMSTC") & ""
iElapsed= DateDiff("h", boats("PositionDate"), now())

Response.Write "Boat" & vbCrLf
Response.Write "Days from last entry" & vbCrLf
Response.Write strBoat & vbCrLf
Response.Write iElapsed \24 & vbCrLf
Response.Write rsBoats("callsign") & vbCrLf
if iElapsed <= 24 then
'24 hours or less
Response.Write & "<img src='boat_okblk.gif'>" & vbCrLf
else
'More than 24 hours
Response.Write & "<img src='boat_lateblk.gif'>" & vbCrLf
end if

Boats.MoveNext
Loop

%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="callsign"
HeaderText="callsign"
ReadOnly="true"
Visible="True"/> ... more

Im getting many errors - Im not sure that mixing versions work.

Help :)
 
Any manipulation of the data in the control should be done via a relevant event in the code behind file. In your case, you probably want to read up on the ItemDataBound event.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top