|
Subject:
|
looping through datagrid
|
|
Posted By:
|
derekl
|
Post Date:
|
1/26/2006 4:23:39 AM
|
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
|
|
Reply By:
|
jbenson001
|
Reply Date:
|
1/26/2006 12:58:13 PM
|
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
|
|
Reply By:
|
rstelma
|
Reply Date:
|
1/26/2006 1:04:21 PM
|
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
|
|
Reply By:
|
jbenson001
|
Reply Date:
|
1/26/2006 1:20:53 PM
|
Does it work...? If so, then use it
|
|
Reply By:
|
rstelma
|
Reply Date:
|
1/26/2006 2:07:28 PM
|
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
|
|
Reply By:
|
derekl
|
Reply Date:
|
2/10/2006 3:21:58 PM
|
Thanks guys, it works.
|
|
Reply By:
|
rstelma
|
Reply Date:
|
2/14/2006 7:19:57 PM
|
What works? Please let us know how you solved the problem.
Much appreciated.
Thanks, Richard
|