Button in footer of a datagrid not firing the event....

S

Stu

Hi,

I have a button in the footer of a datagrid that sometimes does not tigger
the item command. The page is quite large & has a number of homegrown
controls in it. Has anyone come across this type of behaviour before? Can
anyone suggest a solution?

Thanks in advance,
Stu

####################### Handler - Code behind #######################
Public Sub dgOrderDetails_ItemCommand(ByVal source As System.Object, ByVal e
As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgOrderDetails.ItemCommand
Response.Write("My command :: " & e.CommandName & "<br>")
end sub

####################### Datagrid - Page in front #######################
<asp:DataGrid id="dgOrderDetails" runat="server" BorderColor="White"
BorderWidth="0px" CellSpacing="1"
BackColor="White" GridLines="None"
OnItemCommand="dgOrderDetails_ItemCommand" CellPadding="2"
AutoGenerateColumns="False" ShowFooter="True"
DataKeyField="OrderLine_ID">
<Columns>
<asp:TemplateColumn HeaderText="Item">
<ItemTemplate>
<asp:Label runat="server" width="350" Text='<%#
showDesc(DataBinder.Eval(Container, "DataItem.OrderLine_ID")) %>'
ID="Label1" NAME="Label1">
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<!-- ********** FOOTER ********* -->
<asp:DropDownList runat="server"
OnSelectedIndexChanged="SelectedIndexChanged" ID="ddlProducts"
DataValueField="Products_ID"
DataTextField="DisplayName"></asp:DropDownList>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Quantity">
<ItemTemplate>
<asp:Label runat="server" width="40" Text='<%#
showQuantity(DataBinder.Eval(Container, "DataItem.OrderLine_ID")) %>'
ID="lblQnty" >
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<!-- ********** FOOTER ********* -->
<asp:TextBox runat="server" Width="40" ID="txtAddQuantity"
Text="1"></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" Width="40" Text='<%#
showQuantity(DataBinder.Eval(Container, "DataItem.OrderLine_ID")) %>'
ID="txtEditQnty">
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Price">
<ItemTemplate>
<asp:Label runat="server" width="70" Text='<%#
getPrice(DataBinder.Eval(Container, "DataItem.OrderLine_ID")) %>'
ID="lblPrice" NAME="Label3">
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<!-- ********** FOOTER ********* -->
<asp:Label runat="server" ID="lblAddPrice"></asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:Button runat="server" Width="75" Text="edit"
CommandName="edit" CausesValidation="false"
ID="btnEdit"></asp:Button>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center"></FooterStyle>
<FooterTemplate>
<!-- ********** PROBLEM BUTTON ********* -->
<asp:button runat="server" Width="75" ID="btnAdd"
CommandName="add" Text="add" Autopostback="True"></asp:button>
</FooterTemplate>
<EditItemTemplate>
<asp:Button runat="server" Text="update" CommandName="update"
CausesValidation="false" ID="btnUpdateItem"
NAME="btnUpdateItem"></asp:Button>&nbsp;
<asp:Button runat="server" Text="cancel" CommandName="cancel"
CausesValidation="false" ID="btnCancelItem"
NAME="btnCancelItem"></asp:Button>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:Button runat="server" Width="75" Text="delete"
CommandName="delete" CausesValidation="false"
ID="btnDelete"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Right" ForeColor="Black"
BackColor="#C6C3C6"></PagerStyle>
</asp:DataGrid>
 
S

Scott Allen

Hi Stu:

I believe you'll only see ItemCommand events from buttons in the
regular rows of the grid - not the footer. I'd try to handle the Click
event of the event instead.
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top