views:

211

answers:

2

Hello!

This UpdatePanel is contained by an UserControl. When the LinkButton is pressed arow should be added in another GridView. When an user is logged in this control is working well. The problems appears when an user is not logged in and try to push that button. No event triggers. Someone suggested me to give a permission for accessing this control in web.config. That didn't work. Anyone has another idea?

<asp:UpdatePanel runat="server" UpdateMode="Conditional" EnableViewState="true" ID="IngredientsUpdatePanel">
<ContentTemplate>
    <asp:ObjectDataSource ID="sourceIngredients" runat="server" SelectMethod="GetAll">
    </asp:ObjectDataSource>
    <asp:GridView ID="Ingredients" AllowPaging="true" runat="server" DataKeyNames="IngredientId"
        EnableViewState="true" DataSourceID="sourceIngredients" PageSize="5"
        AutoGenerateColumns="false" HorizontalAlign="Center" OnSelectedIndexChanged="Ingredients_SelectedIndexChanged">
         <RowStyle HorizontalAlign="Center"  />  
         <HeaderStyle Font-Bold="true" ForeColor="Black" /> 
         <Columns>                        
                <asp:TemplateField HeaderText="Ingrediente" ItemStyle-Font-Size="10">                
                    <ItemTemplate>
                        <asp:Label ID="lblId" Text='<%# Bind("IngredientId") %>' Visible="false" runat="server"/>
                        <asp:Label ID="lblPrice" Text='<%# Bind("Price") %>' Visible="false" runat="server"/>
                        <asp:Label ID="lblDescr" Text='<%# Bind("Description") %>' Visible="false" runat="server"/>
                        <asp:Label ID="lblName" Text='<%# Bind("Name") %>' Visible="false" runat="server"/>
                        <asp:Label ID="lblPict" Text='<%# Bind("Picture") %>' Visible="false" runat="server"/>
                        <div style="text-align:left;">                        
                            <img id="img" style="float:right;" src='<%# Eval("Picture") %>'
                                height="75" runat="server" alt="Picture" />                                                    
                            <b>
                                <%# Eval("Name") %>
                            </b>
                            <br />
                            <br />
                            Price: <b><%# Eval("Price") %></b>
                            <br />
                            <br />
                            <br />
                        </div>                    
                        <hr />
                        <div style="text-align:left;">
                        <b>Description</b>
                        </div>
                        <div style="width:300px;">
                            <%# Eval("Description") %> 
                        </div>
                        <br />
                        <asp:LinkButton Enabled="true" runat="server" Text="Add" CommandName="Select" ID="cmdAdd" />                           
                       </ItemTemplate>            
                </asp:TemplateField>
             </Columns>
    </asp:GridView>
</ContentTemplate>

A: 

Don't forget to give the webresource.axd enough rights in the web.config?

JSC
Well I don't use that file... But I added that line and it's not working
Ionel Bratianu
+1  A: 

I solved the problem in a tricky way. I deleted the LinkButton and before TemplateField I put a ButtonField and all is working fine. Now the code looks like:

 <Columns>
  <asp:ButtonField Text="Add" CommandName="Select" />                 
      <asp:TemplateField>
            ......
      </asp:TemplateField>
 </Columns>

Still I'm not understanding why the control had that behavior.

Ionel Bratianu