views:

1291

answers:

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>

+2  A: 

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