The repeater template:
<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>
The DB update code:
protected void up_Click1(object sende开发者_StackOverflow中文版r, 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();
}
If I put a brakepoint within the loop, I get a tbArticleOrder.Text = "" each time. I can't figure out why this isn't working. Thank you!
Make sure that you are not re-binding the repeater on the Page PostBack.
Stick the initial code that is Binding the repeater in a !Page.IsPostBack
condition :)
精彩评论