中继器项目内的TextBox为空
本文关键字:TextBox 为空 项目 中继器 | 更新日期: 2023-09-27 17:57:38
中继器模板:
<ItemTemplate>
<div style="width:100%">
<asp:Label style="display:none" ID="ArticleID" runat="server" text='<%# DataBinder.Eval(Container.DataItem, "ArticleID") %>'></asp:Label>
<asp:TextBox ID="ArticleOrder" runat="server" Width="20px" value='<%# DataBinder.Eval(Container.DataItem, "Order") %>'></asp:TextBox>
<a title="Edit Article" href="javascript:void(0)" onclick="parent.document.location.href='/cms/Secured/Article/EditArticle.aspx?ArticleID=<%# DataBinder.Eval(Container.DataItem, "ArticleID") %>'"><%# DataBinder.Eval(Container.DataItem, "Title") %> </a>
<asp:LinkButton id="delll" runat="server" OnCommand ="Del" CommandName ='<%# DataBinder.Eval(Container.DataItem, "ArticleID") %>'>(Delete)</asp:LinkButton>
<a href="javascript:void(0)" onclick="window.open('CategoryArticleLocationReplace.aspx?Action=update&CategoryID=<%# Request.QueryString["CategoryID"].ToString()%>&LocationID=<%# Request.QueryString["LocationID"].ToString()%>&OldArticleID=<%# DataBinder.Eval(Container.DataItem, "ArticleID") %>',null, 'height=200,width=200,status=no,toolbar=no' )">(Replace Article)</a>
</div>
</ItemTemplate>
数据库更新代码:
protected void up_Click1(object sender, EventArgs e)
{
foreach(RepeaterItem _item in rptArticleList.Items)
{
dcLigdol DB = new dcLigdol();
TextBox tbArticleOrder = (TextBox)_item.FindControl("ArticleOrder");
Label lblArticleID = (Label)_item.FindControl("ArticleID");
byte ArticleOrder;
if(tbArticleOrder.Text.Trim() == "")
ArticleOrder = byte.Parse("99");
else
ArticleOrder = byte.Parse(tbArticleOrder.Text.Trim());
int ArticleID = int.Parse(lblArticleID.Text.Trim());
int CategoryID = int.Parse(Request.QueryString["CategoryID"].ToString().Trim());
byte LocationID = byte.Parse(Request.QueryString["LocationID"].ToString().Trim());
DB.spCategory_Article_Location_Order_Update(ArticleID, ArticleOrder, CategoryID, LocationID);
}
Show();
}
如果我在循环中放置一个制动点,每次都会得到一个tbArticleOrder.Text="。我不明白为什么这不起作用。非常感谢。
确保您没有在Page PostBack上重新绑定中继器。
在!Page.IsPostBack
条件下粘贴绑定中继器的初始代码:)