Tutorials to .com

Tutorials to .com » Dotnet » Application » How to use DataGrid to achieve by date to determine whether to display New Logo

How to use DataGrid to achieve by date to determine whether to display New Logo

Print View , by: iSee ,Total views: 13 ,Word Count: 234 ,Date: Wed, 26 Aug 2009 Time: 10:13 AM

Page code is as follows:
<asp: datagrid id = "myGrid1" GridLines = "None" PageSize = "7" ShowHeader = "False" AllowPaging = "True"
CellPadding = "0" AutoGenerateColumns = "False" Height = "100%" Width = "224px" runat = "server">
<ItemStyle Font-Size="12px" HorizontalAlign="Left" VerticalAlign="Middle"> </ ItemStyle>
<Columns>
<asp: HyperLinkColumn DataNavigateUrlField = "ID" DataNavigateUrlFormatString = "Detail.aspx? ID = (0)"
DataTextField = "Title"> </ asp: HyperLinkColumn>
<asp:TemplateColumn>
<ItemTemplate>
<img src ='<%# (Convert.ToInt16 (DataBinder.Eval (Container.DataItem, "DayCount")) <15)? "images / new.gif":
"images / none.gif"%> 'border = "0">
</ ItemTemplate>
</ asp: TemplateColumn>
</ Columns>
<PagerStyle Visible="False"> </ PagerStyle>
</ asp: datagrid>
Background Code:
SqlConnection con = new SqlConnection (ConfigurationSettings.AppSettings [ "strconn"]);
con.Open ();
SqlCommand cmd = new SqlCommand ( "select id, Title, datediff (day, sendDate, getdate ()) as DayCount from NewInfo", con);
SqlDataAdapter da = new SqlDataAdapter (cmd);
DataSet ds = new DataSet ();
da.Fill (ds);
con.Close ();
myGrid1.DataBind ();
/ / sendDate is a DateTime type field refers to the release date of


.Net Application Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.