Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 26th, 2006, 05:23 AM
Authorized User
 
Join Date: Jan 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default looping through datagrid

hi people, i currently doing a private message system. i need to loop through the datagrid to check which message is unread and display a unread icon in the datagrid? anyone know how? or are there alternatives way? thanks alot

 
Old January 26th, 2006, 01:58 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Use the ItemDataBound event of the grid. Check the cell that would tell you if it is read or not, and display an icon if unread. What I have done in the past is to create a template column with and icon in it. Set it's visiblity to FALSE. Then, if it is unread, in your case, get a reference to the icon in the template column, and set Visible = TRUE.

Jim

 
Old January 26th, 2006, 02:04 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

I don't know what is more efficent but here is the code for one of the ways that I use to display Boolean values in the database.

You can see in this code that I write the Boolean value to the image tag. I have a true.gif image and a false.gif image.


<asp:TemplateColumn HeaderText="Status" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<img src='../images/icons/<%#DataBinder.Eval(Container.DataItem,"Status")%>. gif' width='16' height='16' border='0' align='absmiddle'>
</ItemTemplate>
</asp:TemplateColumn>

Richard

 
Old January 26th, 2006, 02:20 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Does it work...? If so, then use it

 
Old January 26th, 2006, 03:07 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

I agree almost 100% with that Jim. Where I disagree is really only when something in the code is happening so bad like some crazy inefficient code looping through endless nested repeaters when just a 'different' SQL statement might pull the same results in one query. Or is it 500 lines of code when it could be done in 50? They both work the same but which is more maintainable? Hey, whatever, really.... if I find something that works I rarely change it.

Regards,
Richard

 
Old February 10th, 2006, 04:21 PM
Authorized User
 
Join Date: Jan 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks guys, it works.

 
Old February 14th, 2006, 08:19 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

What works? Please let us know how you solved the problem.

Much appreciated.

Thanks,
Richard






Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping ssaranam SQL Server 2005 2 April 17th, 2008 01:40 AM
looping mrjoka Classic ASP Basics 1 September 26th, 2007 12:21 AM
Looping through a datagrid DekaFlash VB.NET 2002/2003 Basics 0 February 16th, 2006 10:24 AM
Looping..? dedex C# 2 January 6th, 2005 11:24 PM
looping over datagrid rj1406 Classic ASP Databases 1 September 30th, 2004 08:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.