代码之家  ›  专栏  ›  技术社区  ›  sikender

要在gridview中绑定imagebutton的postbackurl中的querystring吗?

  •  0
  • sikender  · 技术社区  · 16 年前

    当我尝试数据绑定 '<%#Eval("EntryID") %>' 到ImageButton的postbackurl作为

    <asp:ImageButton ID="ibtnEdit" runat="server" CommandName="Edit" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"SystemEmailID")%>'
      ImageUrl="~/Images/edit-list.gif" PostBackUrl="~/Edit_SyatemEmails.aspx?blogentry=edit&id=<%#DataBinder.Eval(Container.DataItem,"SystemEmailID")%>"/>
    
    it's failed, then i updated the code to
    
     <asp:ImageButton ID="ibtnBlogEntryEdit" PostBackUrl='"~/admin/BlogEntry.aspx?blogentry=edit&entryid=" & <%# Eval("EntryID") %>' SkinID="edit" runat="server" />
    
     well,the above code has pass the debugging,but failed to databind to the postbackurl,the result as  
    
    http://localhost/dovoshow/"~/admin/BlogEntry.aspx?blogentry=edit&entryid="%20&%20<%#%20Eval("EntryID")%20%>
    
    so,anyonw know how to solve it ,help me  thanks 
    
    2 回复  |  直到 14 年前
        1
  •  1
  •   Muhammad Akhtar    14 年前

    应该是。。。

    PostBackUrl='<%# Eval("SystemEmailID", "Edit_SyatemEmails.aspx?id={0}"
     + "&blogentry=" + Request.QueryString["edit"]) %>'
    
        2
  •  1
  •   heisthedon    16 年前

    在GridView行创建事件时:

    protected void GridView_OnRowCreated(Object sender, GridViewRowEventArgs e)
    {
        if(e.Row.RowType == DataControlRowType.DataRow)
        {
          (e.Row.FindControl("ibtnEdit") as ImageButton). PostBackUrl = "~/Edit_SyatemEmails.aspx?blogentry=edit&id=" + DataBinder.Eval(e.Row.DataItem, "SystemEmailID"))
        }
    }