datagrid buttons columns not working - help

G

Guest

here is my datagrid, within a <form> tag

<asp:datagrid id="dlUserPhotos" runat="server" GridLines="None"
AutoGenerateColumns="False" OnItemCommand="dlUserPhotos_ItemCommand">
<Columns> <asp:TemplateColumn> <ItemTemplate> <img
src="/images/uploaded/<%# DataBinder.Eval(Container.DataItem,
"path")%>"> </ItemTemplate> </asp:TemplateColumn>
<asp:ButtonColumn Text="Remove" ButtonType="PushButton"
CommandName="RemoveButton" />
<asp:ButtonColumn Text="Default" ButtonType="PushButton"
CommandName="SetDefaultButton" />
<asp:BoundColumn DataField="id" Visible="False" />
</Columns>
</asp:datagrid>

and my code for handling the buttons:

public void dlUserPhotos_ItemCommand(object sender, DataGridCommandEventArgs
e)
{
Functions handle = new Functions();
int selectedID = Convert.ToInt32(e.Item.Cells[3].Text);

if (e.CommandName == "RemoveButton")
{

bool bDeleted = handle.DeletePhoto(selectedID);


}

if (e.CommandName == "SetDefaultButton")
{

bool bSet = handle.UpdateDefaultPhoto(iUserID, selectedID);



}

GetPhotos(iUserID); //Re-bind datagrid
}

I have a break point set on this function but it never gets touched. When I
click Remove Button, it just seems like all I get is a postback.

Have any idea what am I doing wrong here?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top