ASP.NET如何控制Repeater中Item的数量
前台:<asp:RepeaterID="RepeaterData"runat="server"><ItemTemplate><asp:FileUploadID="File...
前台:
<asp:Repeater ID="RepeaterData" runat="server">
<ItemTemplate>
<asp:FileUpload ID="FileUploadImage" runat="server" />
</ItemTemplate>
</asp:Repeater>
<asp:LinkButton ID="LinkButtonAdd" runat="server" Text="添加图片" OnClick="LinkButtonAdd_Click" />
<asp:Label ID="LabelCount" runat="server" Visible="false" />
<asp:Button ID="ButtonUpload" runat="server" Text="批量上传" />
后台:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LabelCount.Text = "1";
Load_Repeater();
}
}
void Load_Repeater()
{
int count = Convert.ToInt32(LabelCount.Text);
DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
for (int i = 0; i < count; i++)
{
dr = dt.NewRow();
dt.Rows.Add(dr);
}
RepeaterData.DataSource = dt;
RepeaterData.DataBind();
}
protected void LinkButtonAdd_Click(object sender, EventArgs e)
{
int count = Convert.ToInt32(LabelCount.Text);
count++;
LabelCount.Text = count.ToString();
Load_Repeater();
}
动态控制 <asp:FileUpload ID="FileUploadImage" runat="server" />的数量
void Load_Repeater()有没有好的方法 展开
<asp:Repeater ID="RepeaterData" runat="server">
<ItemTemplate>
<asp:FileUpload ID="FileUploadImage" runat="server" />
</ItemTemplate>
</asp:Repeater>
<asp:LinkButton ID="LinkButtonAdd" runat="server" Text="添加图片" OnClick="LinkButtonAdd_Click" />
<asp:Label ID="LabelCount" runat="server" Visible="false" />
<asp:Button ID="ButtonUpload" runat="server" Text="批量上传" />
后台:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LabelCount.Text = "1";
Load_Repeater();
}
}
void Load_Repeater()
{
int count = Convert.ToInt32(LabelCount.Text);
DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
for (int i = 0; i < count; i++)
{
dr = dt.NewRow();
dt.Rows.Add(dr);
}
RepeaterData.DataSource = dt;
RepeaterData.DataBind();
}
protected void LinkButtonAdd_Click(object sender, EventArgs e)
{
int count = Convert.ToInt32(LabelCount.Text);
count++;
LabelCount.Text = count.ToString();
Load_Repeater();
}
动态控制 <asp:FileUpload ID="FileUploadImage" runat="server" />的数量
void Load_Repeater()有没有好的方法 展开
2016-03-15 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
ASP.NET控制Repeater中Item的数量的方法是用for循环累计。
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource2"
EnableViewState="False">
<HeaderTemplate>
<table>
<tr>
</HeaderTemplate>
<ItemTemplate>
<td><%# Eval("CategoryName") %></td>
</ItemTemplate>
<FooterTemplate>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询