2011-05-26 46 views
2

中繼模板:文本框的repeater項目內空

<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> 

數據庫更新代碼:

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(); 
} 

如果我把循環內的brakepoint,我得到一個tbArticleOrder.Text = 「」 每時間。 我不明白爲什麼這不起作用。 謝謝!

+0

你是不是再結合上後的中繼回你最初的代碼? – 2011-05-26 08:43:10

+0

Show()函數重新綁定中繼器,但這只是更新後。這是按鈕點擊的整個處理程序。 – 2011-05-26 08:45:31

+1

當頁面加載時,你最初綁定中繼器,這是在「!Page.IsPostBack」? – 2011-05-26 08:46:36

回答

5

確保您沒有重新綁定Page PostBack上的中繼器。

棒被綁定中繼器在!Page.IsPostBack條件:)