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>

cdonner
  • 37,019
  • 22
  • 105
  • 153
  • 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. – David Andres Sep 19 '09 at 19:57

1 Answers1

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;
Canavar
  • 47,715
  • 17
  • 91
  • 122
  • 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! – cdonner Sep 19 '09 at 20:05