using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;using System.Text;
using System.IO;
using System.Data; public partial class DownloadItem_CmdExeItem : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ if (!IsPostBack)
{
Btn_Commit_BCF.Attributes.Add("OnClick", "javascript:return confirm('您确定提交吗?!');"); } }
protected void Btn_search_BCF_Click(object sender, EventArgs e)
{
InitData();
rpt_BCF_DataBinds();
TotalControls = Rpt_BCF.Items.Count;
for (int i = ; i < TotalControls; i++)
{
(Rpt_BCF.Items[i].FindControl("DropDownList1") as DropDownList).Enabled = false; }
}
protected void Rpt_BCF_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
(e.Item.FindControl("DropDownList1") as DropDownList).SelectedValue = DDL_Seach_City.SelectedItem.Value;
}
}
protected void Btn_addline_BCF_Click(object sender, EventArgs e)
{
DataTable dt = CopyFormData();
Random rd_year = new Random(), rd_month = new Random(), rd_date = new Random();
string datestr = rd_year.Next(, ).ToString("d4") + "/" + rd_month.Next(, ).ToString("d2") + "/" + rd_date.Next(, ).ToString("d2");
DataRow dr = dt.NewRow(); dr["HIDUKE"] = datestr;//DateTime.Now.Date.ToString();
dr["PV_CNT"] = -;
dr["CL_CNT"] = -;
dt.Rows.Add(dr); ViewState.Add("Data", dt); rpt_BCF_DataBinds();
for (int i = ; i < TotalControls; i++)
{
(Rpt_BCF.Items[i].FindControl("DropDownList1") as DropDownList).Enabled = false;
(Rpt_BCF.Items[i].FindControl("TextBox2") as TextBox).Enabled = false;
(Rpt_BCF.Items[i].FindControl("Btn_repcld") as Button).Enabled = false; } Btn_search_BCF.Enabled = false; }
private void Phl_table_addline(int num)
{
//for (int i = 0; i < num; i++)
//{
TableRow tr;
TableCell tc;
DropDownList ddl_citydynamic;
ListItem li;
Calendar cld;
TextBox Tbox_date, Tbox_pvno, Tbox_clno;
Button Btn_chosedate;
//if(IsPostBack)
//{ tr = new TableRow(); tc = new TableCell();
ddl_citydynamic = new DropDownList();
li = new ListItem("请xx", "-1");
ddl_citydynamic.Items.Add(li);
li = new ListItem("xxx", "");
ddl_citydynamic.Items.Add(li);
li = new ListItem("xxx", "");
ddl_citydynamic.Items.Add(li);
li = new ListItem("xxx", "");
ddl_citydynamic.Items.Add(li);
li = new ListItem("xxx", "");
ddl_citydynamic.Items.Add(li);
li = new ListItem("xxx", "");
ddl_citydynamic.Items.Add(li);
tc.Controls.Add(ddl_citydynamic);
tr.Cells.Add(tc); tc = new TableCell();
Tbox_date = new TextBox();
Btn_chosedate = new Button();
Btn_chosedate.Text = "▼";
tc.Controls.Add(Tbox_date);
tc.Controls.Add(Btn_chosedate);
tr.Cells.Add(tc); tc = new TableCell();
Tbox_pvno = new TextBox();
tc.Controls.Add(Tbox_pvno);
tr.Cells.Add(tc); tc = new TableCell();
Tbox_clno = new TextBox();
tc.Controls.Add(Tbox_clno);
tr.Cells.Add(tc); tc = new TableCell();
tr.Cells.Add(tc); //tbl_BCF.Rows.Add(tr);
//} }
protected int CurrentItem
{
get
{
return ViewState["CurrentItem"] == null ? : (int)(ViewState["CurrentItem"]);
}
set
{
ViewState["CurrentItem"] = value;
}
}
protected int TotalControls
{
get
{
return ViewState["TotControls"] == null ? : (int)(ViewState["TotControls"]);
}
set
{
ViewState["TotControls"] = value;
}
}
protected void rpt_BCF_DataBinds()
{
Rpt_BCF.DataSource = ViewState["Data"] as DataTable;
Rpt_BCF.DataBind();
}
protected DataTable CopyFormData()
{
DataTable dt = (ViewState["Data"] as DataTable).Clone(); foreach (RepeaterItem ri in Rpt_BCF.Items)
{
DataRow dr = dt.NewRow(); dr["xxx"] = (ri.FindControl("TextBox1") as TextBox).Text; dt.Rows.Add(dr);
} return dt;
} protected void InitData()
{
DateTime time = DateTime.Now; DataTable dt = new DataTable(); StringBuilder sb = new StringBuilder();
sb.Append("select xxx,xxx,xxx,xxx from 00 where "); if (DDL_Seach_City.SelectedItem.Text != "请选择")
sb.Append("xxx='" + DDL_Seach_City.SelectedItem.Text + "' and ");
if (TBox_Datebegin.Text.Length == && TBox_Dateend.Text.Length == )
sb.Append("xxx>='" + TBox_Datebegin.Text + "' and xxx<='" + TBox_Dateend.Text + "' and ");
else if (TBox_Datebegin.Text.Length == )
sb.Append("xxx='" + TBox_Datebegin.Text + "' and "); if (sb.Length <= )
{ }
else
{ string sqlstr = sb.ToString().Substring(, sb.Length - );
BCF bcfr = new BCF();
dt = bcfr.search_BCF(sqlstr);
} ViewState.Add("Data", dt);
}
protected void Btn_repcld_Click(object sender, EventArgs e)
{
RepeaterItem rptItem = ((Button)sender).Parent as RepeaterItem;
CurrentItem = rptItem.ItemIndex;
Div_Cld_common.Style["Display"] = "Block";
}
protected void Cld_common_SelectionChanged(object sender, EventArgs e)
{
(Rpt_BCF.Items[CurrentItem].FindControl("TextBox2") as TextBox).Text = Cld_common.SelectedDate.ToShortDateString();
Div_Cld_common.Style["Display"] = "None";
}
}

前台:

<div class="new_area_BCF">
<table style="width: 900px; text-align: center; align-self: center;">
<tr>
<td class="auto-style1">
<asp:Label ID="Label1" runat="server" Text="城市"></asp:Label><asp:DropDownList ID="DDL_Seach_City" runat="server">
<asp:ListItem Text="请选择" Value="-1"></asp:ListItem>
<asp:ListItem Text="xx" Value="1"></asp:ListItem>
<asp:ListItem Text="xx" Value="2"></asp:ListItem>
<asp:ListItem Text="xx" Value="3"></asp:ListItem>
<asp:ListItem Text="xx" Value="4"></asp:ListItem>
<asp:ListItem Text="xx" Value="5"></asp:ListItem>
</asp:DropDownList></td> <td style="text-align: right;" class="auto-style1">
<asp:Label ID="Label2" runat="server" Text="日期"></asp:Label>
<asp:TextBox ID="TBox_Datebegin" runat="server"></asp:TextBox>
<asp:Button ID="Btn_Datebegin" runat="server" Text="▼" OnClick="Btn_Datebegin_Click" />~
</td>
<td style="text-align: left;" class="auto-style1">
<asp:TextBox ID="TBox_Dateend" runat="server"></asp:TextBox>
<asp:Button ID="Btn_Dateend" runat="server" Text="▼" OnClick="Btn_Dateend_Click" />
</td>
<td class="auto-style1">
<asp:Button ID="Btn_search_BCF" runat="server" Text="检索" OnClick="Btn_search_BCF_Click" /><asp:Button ID="Btn_addline_BCF" OnClick="Btn_addline_BCF_Click" runat="server" Text="+" />
</td>
<td class="auto-style1"></td>
</tr>
<tr>
<td></td>
<td style="text-align: right;">
<asp:Calendar ID="Cld_begin" Visible="false" runat="server" OnSelectionChanged="Cld_begin_SelectionChanged"></asp:Calendar>
</td>
<td style="text-align: left;">
<asp:Calendar ID="Cld_end" Visible="false" runat="server" OnSelectionChanged="Cld_end_SelectionChanged"></asp:Calendar>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="5">
<asp:Repeater ID="Rpt_BCF" runat="server" OnItemDataBound="Rpt_BCF_ItemDataBound">
<HeaderTemplate>
<table class="Rpt_table_BCF">
<tr>
<th>xx</th>
<th>xx</th>
<th>xx</th>
<th>xx</th>
<th></th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class="tr_white_BCF">
<td>
<asp:DropDownList ID="DropDownList1" runat="server" OnDataBinding="DropDownList1_DataBinding">
<asp:ListItem Text="请选择" Value="-1"></asp:ListItem>
<asp:ListItem Text="xxx" Value="1"></asp:ListItem>
<asp:ListItem Text="xxx" Value="2"></asp:ListItem>
<asp:ListItem Text="xxx" Value="3"></asp:ListItem>
<asp:ListItem Text="xxx" Value="4"></asp:ListItem>
<asp:ListItem Text="xxx" Value="5"></asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="TextBox1" Text='<%#Eval("xxx")%>' Visible="false" runat="server"></asp:TextBox></td>
<td>
<asp:TextBox ID="TextBox2" Text='<%#Eval("xxx")%>' runat="server"></asp:TextBox><asp:Button ID="Btn_repcld" OnClick="Btn_repcld_Click" runat="server" Text="▼" /></td>
<td>
<asp:TextBox ID="TextBox3" Text='<%#Eval("xxx")%>' runat="server"></asp:TextBox></td>
<td>
<asp:TextBox ID="TextBox4" Text='<%#Eval("xxx")%>' runat="server"></asp:TextBox></td>
<td></td>
</tr>
</ItemTemplate>
<%--<AlternatingItemTemplate>
<tr class="tr_black_BCF">
<td><%#Eval("xxx")%></td>
<td><%#Eval("xxx")%></td>
<td>
<asp:TextBox ID="TextBox1" Text='<%#Eval("xxx")%>' runat="server"></asp:TextBox></td>
<td>
<asp:TextBox ID="TextBox2" Text='<%#Eval("xxx")%>' runat="server"></asp:TextBox></td>
<td>
</td>
</tr>
</AlternatingItemTemplate>--%>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<div id="Div_Cld_common" runat="server">
<asp:Calendar ID="Cld_common" runat="server" OnSelectionChanged="Cld_common_SelectionChanged"></asp:Calendar>
</div>
</td> </tr>
<tr>
<td colspan="5" style="text-align: right;">
<asp:Button ID="Btn_Commit_BCF" runat="server" Text="提交" OnClick="Btn_Commit_BCF_Click" /></td> </tr>
<tr><td><p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</p></td></tr>
</table>
</div>

ASP.NET Repeater 绑定 DropDownList Calendar 选择日期的更多相关文章

  1. Asp.Net MVC绑定DropDownList等控件

    测试环境:vs2013..Net4.5.mvc5 一.Asp.Net MVC绑定控件原理说明 以Html.TextBox为例 /// <param name="name"&g ...

  2. repeater绑定dropdownlist,jquery+ajax页面无刷新,修改dropdownlist默认值

    html代码: <td>                        <asp:HiddenField ID="hiddenchuli" Value='< ...

  3. ASP.NET - List<> 绑定 DropDownList

    代码: //声明泛型 List<category> inof = new List<category>();//二级分类 //声明类使用的对象类 public class ca ...

  4. asp.net 弹出式日历控件 选择日期 Calendar控件

    原文地址:asp.net 弹出式日历控件 选择日期 Calendar控件 作者:逸苡 html代码: <%@ Page Language="C#" CodeFile=&quo ...

  5. 【2017-05-19】WebForm复合控件、用DropDownList实现时间日期选择。

    自动提交的属性: AutoPostBack="True" 1.RadioButtonList     单选集合 -属性:RepeatDirection:Vertical (垂直排布 ...

  6. 《ASP.NET》数据绑定—DropDownList、ListBox

    DropDownList和ListBox实现两级联动功能.他们也能够将从后台数据库中搜选的出来的信息加以绑定.这里要实现的功能是在DropDownList中选择"省",然后让Lis ...

  7. "不能在 DropDownList 中选择多个项。"其解决办法及补充

    探讨C#.NET下DropDownList的一个有趣的bug及其解决办法 摘要: 本文就C#.Net 环境下Web开发中经常使用的DropDownList控件的SelectedIndex属性进行了详细 ...

  8. asp.net mvc中DropDownList

    asp.net mvc中DropDownList的使用. 下拉列表框 以分为两个部分组成:下拉列表和默认选项 DropDownList扩展方法的各个重载版本基本上都会传递到这个方法上:   publi ...

  9. 不能在DropDownList 中选择多个项

    在绑定DropDownList时如果出现多次绑定,会出错以下错误: “不能在DropDownList 中选择多个项” 经了解,只需要在选中值是清空选择即可:xxDropDownList.ClearSe ...

随机推荐

  1. Android pull解析xml文件

    本文介绍android中使用pull来解析xml文件 先自己写一个xml文件,存一些天气信息 <?xml version="1.0" encoding="UTF-8 ...

  2. 运算符&,|,^

    1.&按位“与”的计算是把两个数字分别写成二进制形式,然后按照每一位进行比较,&计算中,只要有一个是0就算成02.|运算转换成2进制进行比较,两个位只要有一个为1,那么结果就是1,否则 ...

  3. Java核心:类加载和JVM内存的分配

    类的加载: 指的是将class文件的二进制数据读入到运行时数据区(JVM在内存中划分的) 中,并在方法区内创建一个class对象. 类加载器: 负责加载编译后的class文件(字节码文件)到JVM(J ...

  4. 【Android】不使用WebView来执行Javascript脚本(Rhino)

    前言 动态执行脚本能有效的降低重要功能硬编码带来的问题,尤其是依赖于第三方的应用,可以通过动态脚本+在线参数(例如友盟在线参数)再不更新应用的情况下升级功能. 声明 欢迎转载,但请保留文章原始出处:) ...

  5. iOS开发--关于TableViewCell的可视化设置细节

    由于时间问题,本篇博文很简略. 1.关于设置Cell的边距问题

  6. Java基础知识学习(九)

    GUI开发 先前用Java编写GUI程序,是使用抽象窗口工具包AWT(Abstract Window Toolkit).现在多用Swing.Swing可以看作是AWT的改良版,而不是代替AWT,是对A ...

  7. 今天说一下Order by 这个常规东西~

    Order by 在我们日常的数据库开发生活中是出镜率灰常高的. order by 的作用就是用于对查询出来的结果进行排序~对啊~人家就是这么接地气~比如按发生时间啊,首字母啊之类的都是相当常见. 今 ...

  8. Servlet/JSP-08 EL表达式

    EL - Expression Language 一. 基本语法 EL表达式以 ${} 的形式访问变量的值 1. "." 和 "[]" 运算符 <%@ p ...

  9. file

    用来测试文件类型 $file [] filename -b列出辨识结果时,但不显示文件名称 -L如果文件是符号链接,那么直接解读其指向的文件 -z:如果文件是压缩文件,尝试去解读压缩文件的内容 $fi ...

  10. sed grep find命令

    一.sed [-nerf][n1,n2] action -n 安静模式,只有经过sed处理过的行才显示出来,其他不显示. -r 表示sed支持扩展的正则表达式 -e 表示直接在命令行模式上进行sed操 ...