1

Scratching my head about this. In the rendered HTML for the code below, the btnEdit (in the GridView) has the correct Javascript in the onclick parameter (onclick="javascript:WebForm_DoPostBack..."). The btnAddNew has no onclick handler at all. Why? There is no compilation or runtime error, and the page uses a master page that has the Form tag..

<ContentTemplate>
<asp:ImageButton ID="btnAddNew" SkinID="btnAddNew" runat="server" 
    PostBackUrl='<%# "EditUser.aspx?action="+Constants.actionAdd %>' /> 
<asp:GridView ID="UserGridView" 
      runat="server" 
      DataKeyNames="UserId" 
      >  
      <Columns>
        <asp:TemplateField
              <ItemTemplate>
                  <asp:ImageButton id="btnEdit" SkinID="btnEdit" runat="server" 
                    PostBackUrl='<%# Eval("UserId", "EditUser.aspx?
                     action="+Constants.actionEdit+"&uid={0}") %>' />
              </ItemTemplate>
        </asp:TemplateField>                                        
      </Columns>          
</asp:GridView>

1
  • Check if the PostBackUrl makes its way to the rendered page intact. If so, then the asp:ImageButton control does not have a PostBackUrl property. Commented Sep 19, 2009 at 19:57

1 Answer 1

4

it looks like you don't need data binding tag (<%#) for the btnAddNew button. So you can assign this property at server side :

btnAddNew.PostBackUrl = "EditUser.aspx?action=" + Constants.actionAdd;
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, works of course. Not only do I not need the data binding evaluator tag, but I cannot use it on an item that it is not data-bound. Duh!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.