473,383 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

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
1 1646
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
0
by: Oz | last post by:
Hi Using VS.NET 2003, Windows XP SP1, We have a page which has been developed using ASP.NET. On it, is a button which when clicked is supposed to add some data to a table. When the button is...
3
by: Utter Newbie | last post by:
Anyone know what could be the problem? I gave the button in the footer a command name but when the button is clicked the datagrid_itemcommand event is never fired (tracing it in the debugger)? It...
2
by: sri_san | last post by:
Hello group, I have a datagrid(dg) and a couple of buttons outside the dg( 'New'& 'Done'). Have a 'save' button inside the dg that responds to itemcommand event. On a 'New' button click, the...
2
by: Andy Sutorius via DotNetMonster.com | last post by:
Hi, I have a delete button in the item template of my datagrid, when I click it the function for the Insert button is executed instead of the delete button. When I step through in debug, the...
5
by: csgraham74 | last post by:
Hi guys, I posted regarding this issue the other day but i still dont have an answer to my problem. Basically i have imported asp.net pages from dreamweaver into visual studio. Ive added a...
4
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
5
by: Jeff User | last post by:
Hello ..NET 1.1, VS 2003, C# & asp.net I have tried to follow msdn instructions and samples but I can not get an event to fire for this button on the datagrid. There has to be something obvious...
7
by: rsaffy | last post by:
I am having trouble with my dynamically created button's event handling. I read that the buttons need to be recreated on every trip to the server, but how exactly do you do that when the datagrid...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.