By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

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

P: n/a
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>
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 27 Jun 2005 17:29:25 +0100, "Stu" <s.****@cergis.com> wrote:
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>


Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.