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

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.