c#
  • asp.net
  • gridview
  • query-string
  • 2010-03-17 3 views 0 likes 
    0

    lorsque je tente de DataBind le '<%#Eval("EntryID") %>' commeVous voulez lier querystring dans postbackurl de imagebutton dans gridview?

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

    Pouvez-vous montrer le code où vous faites DataBind? –

    +0

    base de données à codebehind sur l'événement pageload en créant une fonction. – sikender

    Répondre

    1

    de PostBackUrl du ImageButton Il devrait être comme ...

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

    Je vous suggère de le faire dans le code derrière. En GridView événement RowCreated:

    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")) 
        } 
    } 
    
    Questions connexes