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