开发者

Want to bind querystring in postbackurl of imagebutton in gridview?

when i try to databind the '<%#Eval("EntryID") %>' to the ImageButton's postbackurl as

<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("Ent开发者_开发百科ryID") %>' 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 


It should be like...

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


I would suggest you to do it in the code behind. On GridView RowCreated event:

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"))
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜