本文介绍了如何在asp.net中验证转发器控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 源页面代码如下 < div > < asp:Repeater ID = Repeater1 runat = server > < HeaderTemplate > ; < table border = 0 width = 600px cellpadding = 2 cellspacing = 1 样式 = border:1px solid maroon ; > < tr bgcolor = maroon > < th > course < / th > < th > Courseamt​​ < / th > < th > Coursedate < / th > < / tr > < / HeaderTemplate &克t; < itemtemplate > < tr > < td width = 100 > <%#DataBinder.Eval( Container, DataItem.course)%> < / td > < td > <%#DataBinder.Eval(Container, DataItem.Courseamt​​)%> < / td > < td width = 150 > <%#DataBinder.Eval(Container, DataItem.Coursedate)%> < / td > < / tr > < / itemtemplate > < alternatingitemtemplate > < tr bgcolor = #e8e8e8 > < td width = 100 > <%#DataBinder.Eval(Container, DataItem.course)%> < / td > < td > <%#DataBinder.Eval(Container, DataItem.Courseamt​​)%> < / td > < td width = 150 > <%#DataBinder.Eval(Container, DataItem.Coursedate)%> < / td > > < / tr > < / alternatingitemtemplate > < footertemplate > ; < / footertemplate > < / table > ; < asp:Button ID = 提交 runat = server / > < div style = font-size:14px;颜色:海军 > < / div > < / div > 我的代码如下 受保护 void Page_Load( object sender,EventArgs e) { SqlConnection con = new SqlConnection( Server =(local); initial catalog = Himt_Testing; Trusted_Connection = True); string str; SqlCommand cmd = new SqlCommand( select * from Tb_Course_details,con); cmd.Connection.Open(); Repeater1.DataSource = cmd.ExecuteReader(); Repeater1.DataBind(); cmd.Connection.Close(); } 当我运行上面的代码时,在转发器控件中显示如下输出 Coursename Amount Coursedate RPST 400 29 Apr 14 RPSCRB 500 30 Apr 14 然后我有一个叫做提交的按钮。 当我点击提交按钮时,我必须显示RPST和RPSCRB课程必须是同一日期的消息。 我怎么能用转发器控制来验证。 已添加 pre 标签。 [/编辑] 解决方案 尝试 http://forums.asp.net/ t / 1774765.aspx?验证+ a + custom + validator + in + a + Repeater + control [ ^ ] 使用复选框验证转发器控件 [ ^ ] http://www.chrislord.me/blog/aspnet-validation-control-inside-a-repeater-or- listview / [ ^ ] Source page code as follows<div><asp:Repeater ID="Repeater1" runat="server"><HeaderTemplate><table border="0" width="600px" cellpadding="2" cellspacing="1" style="border: 1px solid maroon;"><tr bgcolor="maroon"><th>course</th><th>Courseamt</th><th>Coursedate</th></tr></HeaderTemplate><itemtemplate><tr><td width="100"><%# DataBinder.Eval(Container, "DataItem.course")%></td><td><%# DataBinder.Eval(Container, "DataItem.Courseamt")%></td><td width="150"><%# DataBinder.Eval(Container, "DataItem.Coursedate")%></td></tr></itemtemplate><alternatingitemtemplate><tr bgcolor="#e8e8e8"><td width="100"><%# DataBinder.Eval(Container, "DataItem.course")%></td><td><%# DataBinder.Eval(Container, "DataItem.Courseamt")%></td><td width="150"><%# DataBinder.Eval(Container, "DataItem.Coursedate")%></td>></tr></alternatingitemtemplate><footertemplate></footertemplate></table>     <asp:Button ID="Submit" runat="server" /><div style="font-size:14px; color:Navy">  </div></div>My code as followsprotected void Page_Load(object sender, EventArgs e){ SqlConnection con = new SqlConnection("Server=(local);initial catalog=Himt_Testing;Trusted_Connection=True"); string str; SqlCommand cmd = new SqlCommand("select * from Tb_Course_details", con); cmd.Connection.Open(); Repeater1.DataSource = cmd.ExecuteReader(); Repeater1.DataBind(); cmd.Connection.Close();}when i run the above code shows output as follows in repeater controlCoursename Amount CoursedateRPST 400 29 Apr 14RPSCRB 500 30 Apr 14Then i have one button called Submit.When i click submit button,i have to show the message the RPST and RPSCRB course must be same date.for that how can i validate using repeater control.[Edit member="Tadit"]Added pre tags.[/Edit] 解决方案 Tryhttp://forums.asp.net/t/1774765.aspx?Validate+a+custom+validator+in+a+Repeater+control[^]validate the repeater control using checkbox[^]http://www.chrislord.me/blog/aspnet-validation-control-inside-a-repeater-or-listview/[^] 这篇关于如何在asp.net中验证转发器控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-22 23:49