开发者

TextBox inside repeater item empty

开发者 https://www.devze.com 2023-03-08 07:03 出处:网络
The repeater template: <ItemTemplate> <div style=\"width:100%\"> <asp:Label style=\"display:none\" ID=\"ArticleID\" runat=\"server\" text=\'<%# DataBinder.Eval(Container.DataItem, \

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> 
                    &nbsp;
                    <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>
                    &nbsp;
                    <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>
                    &nbsp;

                </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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号