当前位置:编程学习 > C#/ASP.NET >>

怎样获取datalist里hyperlink上绑定的两个拼接时间,并且把获取的两个时间跟从数据库查询到的另个时间比较

我想得到的效果是:把页面绑定的两个时间获取到,跟数据库里查询的时间做比较,看看数据库里的时间是否是在页面绑定的时间段内。如果不在页面上这个时间段内就让它显示为红色!
這是我寫的代易做图:
<asp:DataList ID="dLOwner" runat="server" CellPadding="4" ForeColor="#333333"
                                                         DataKeyField="PC_Id" Width="90%" CssClass="datalist_style" 
                                                    onitemdatabound="dLOwner_ItemDataBound">
                                                    <ItemTemplate><img src="Images/axn_20.gif" alt="" />
                                                        <asp:HyperLink ID="content" runat="server" Target="_blank" Text='<%# "    "+string.Format("{0:d}",Eval("PC_Plan.Plan_DateFrom"))+"~"+ string.Format("{0:d}",Eval("PC_Plan.Plan_DateEnd"))+"        "+ CommonFun.SubStr(Convert.ToString(Eval("PC_Content")), 16) %>' 
                                                            NavigateUrl='<%# String.Format("~/WorkPlanManage/WorkPlan_ViewByPlanId.aspx?PC_Id={0}",Eval("PC_Id"))%>'>
                                                       </asp:HyperLink>
                                                       <asp:Label ID="content1" runat="server" Visible="false" Text='<%# string.Format("{0:d}",Eval("PC_Plan.Plan_DateFrom"))+"~"+ string.Format("{0:d}",Eval("PC_Plan.Plan_DateEnd"))+"/"+CommonFun.SubStr(Convert.ToString(Eval("PC_Content")), 16)%>'></asp:Label>
                                                     </ItemTemplate>           
                                                    <SelectedItemStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                              </asp:DataList>


我要在后台取到hyperlink绑定的两个日期,再和数据库里另一张表里的时间字段做比较,请问该怎么做?望高手们,行行好,告诉我!感激不尽~ --------------------编程问答-------------------- 感觉好乱啊。。。。 --------------------编程问答--------------------  DateTime dat1 = Convert.ToDateTime("2011-03-01");
 DateTime dat2 = Convert.ToDateTime("2011-03-10");
if(dat1.CompareTo(dat2) > 0)
{
  ......
}
else
{
  .......
} --------------------编程问答--------------------


<asp:DataList ID="dLOwner" runat="server" CellPadding="4" ForeColor="#333333"
  DataKeyField="PC_Id" Width="90%" CssClass="datalist_style"  
  onitemdatabound="dLOwner_ItemDataBound">
  <ItemTemplate><img src="Images/axn_20.gif" alt="" />
  <asp:HyperLink ID="content" runat="server" Target="_blank" Text='<%# "    "+string.Format("{0:d}",Eval("PC_Plan.Plan_DateFrom"))+"~"+ string.Format("{0:d}",Eval("PC_Plan.Plan_DateEnd"))+"        "+ CommonFun.SubStr(Convert.ToString(Eval("PC_Content")), 16) %>'  
  NavigateUrl='<%# String.Format("~/WorkPlanManage/WorkPlan_ViewByPlanId.aspx?PC_Id={0}",Eval("PC_Id"))%>'>
  </asp:HyperLink>
  <asp:Label ID="content1" runat="server" Visible="false" Text='<%# string.Format("{0:d}",Eval("PC_Plan.Plan_DateFrom"))+"~"+ string.Format("{0:d}",Eval("PC_Plan.Plan_DateEnd"))+"/"+CommonFun.SubStr(Convert.ToString(Eval("PC_Content")), 16)%>'></asp:Label>
  </ItemTemplate>   
  <SelectedItemStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
  </asp:DataList>


--------------------编程问答-------------------- 对的啊,可以像2楼那样啊!!
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,