0

im building a site that places galleries within an itemTemplate, each gallery has its own ID, im tring to allow each gallery to have its own "edit" button, this will allow the user to delete or rename the gallery etc. is it possible to make the button ID the same as the gallery ID? then when the button is clicked the ID will be passed to another page that will allow the user to make changes to the gallery. iv tried the following but its not liking it. is there a better way to pass the particular gallery id to another page?

<ItemTemplate> 
              <ul class="thumbnails gallery">
                <li class="gallery">
                       <a style="text-decoration:none;" href="galleryData.aspx?gallery_id=<%#Eval("gallery_id") %>">
                          <img alt="<%#Eval("gallery_name") %>" style="border:0px;" src="photo_load.aspx?gallery_id=<%#Eval("gallery_id") %>&thumbnail=1" />
                          <span class="below-image"><%#Eval("gallery_name") %></span>
                       </a>    
                        <asp:Button ID="<%=(Request.QueryString["gallery_id"]).ToString() %>" runat="server" onClick="Button1_Click" Visible="true" Text="Edit" />
                </li>
              </ul>
              
                
             
            </ItemTemplate>

thanks for any replies

Edited by barriegrant1: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by barriegrant1
0

You could consider using a linkbutton. Then you can pass the gallery id via the command argument of the link button.

<li class="gallery">
<a style="text-decoration:none;" href="galleryData.aspx?gallery_id=<%#Eval("gallery_id") %>">
<img alt="<%#Eval("gallery_name") %>" style="border:0px;" src="photo_load.aspx?gallery_id=<%#Eval("gallery_id") %>&thumbnail=1" />
<span class="below-image"><%#Eval("gallery_name") %></span>
</a>
<asp:LinkButton ID="LinkButton1" runat="server" CommandArgument="<%#Eval("gallery_id") %>" onclick="LinkButton1_Click">LinkButton</asp:LinkButton>
</li>

And then in your code behind access the commandArgument of LinkButton1.

0

thanks alot hericles, it worked great, i used the following:

<asp:LinkButton ID="LinkButton" runat="server"  OnCommand="LinkButton1_Click" CommandName='<%#bind("gallery_name") %>' CommandArgument='<%#Eval("gallery_id") %>'>LinkButton</asp:LinkButton>

code behind

protected void LinkButton1_Click(Object sender, CommandEventArgs e)
        {
           string gal_name  = (Convert.ToString(e.CommandName));
           var gal_id  = (Convert.ToString(e.CommandArgument));

           Response.Redirect(string.Format("galleryEdit.aspx?" + "galleryID={0}" + "&galleryName={1}", gal_id, gal_name)); //pass the gallery_id value to the galleryEdit page
        }

thanks again

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.