Hello Group,
I use a datagrid with a linkbutton to delete the selected
row.
Added javascript confirm dialogue box in itembound event. The
itemCommand event does not seem to fire when I debug the application.
Any ideas?
Code outline below:
<asp:datagrid id="dbgrdCandid ate_List" ForeColor="Blac k" runat="server"
Width="848px" DataKeyField="C andidate_Id" AllowSorting="T rue"
AutoGenerateCol umns="False" ShowHeader="Fal se" EnableViewState ="False">
<asp:TemplateCo lumn>
<ItemStyle Width="45px"></ItemStyle>
<ItemTemplate >
<asp:LinkButt on id="delbutton" runat="server" Width="35" Text="Delete "
CommandName="De lete"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateCol umn>
'Code Behind
Private Sub dbgrdCandidate_ List_ItemComman d(ByVal source As Object,
ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
dbgrdCandidate_ List.ItemComman d
If InStr(e.Command Name, "Delete") Then
'Delete Logic goes here.. ..
End If
End Sub
Thanks,
Sam. 3 5009
You need to have ViewState on...
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
<sr*****@mailci ty.com> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.com... Hello Group, I use a datagrid with a linkbutton to delete the selected row. Added javascript confirm dialogue box in itembound event. The itemCommand event does not seem to fire when I debug the application. Any ideas?
Code outline below:
<asp:datagrid id="dbgrdCandid ate_List" ForeColor="Blac k" runat="server" Width="848px" DataKeyField="C andidate_Id" AllowSorting="T rue" AutoGenerateCol umns="False" ShowHeader="Fal se" EnableViewState ="False">
<asp:TemplateCo lumn> <ItemStyle Width="45px"></ItemStyle> <ItemTemplate > <asp:LinkButt on id="delbutton" runat="server" Width="35" Text="Delete "
CommandName="De lete"></asp:LinkButton> </ItemTemplate> </asp:TemplateCol umn>
'Code Behind
Private Sub dbgrdCandidate_ List_ItemComman d(ByVal source As Object, ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles dbgrdCandidate_ List.ItemComman d If InStr(e.Command Name, "Delete") Then 'Delete Logic goes here.. .. End If End Sub
Thanks, Sam.
Thanks for the reply. It works when I enable the viewstate. Not sure
how are the two connected?
Thanks,
Sam.
Sam:
You are only binding when not posting back (ie, on the initial page load)
If Not Page.IsPostBack Then
'DataBind()
end if
When you click the button, all that rendered HTML is lost. With viewstate
enable, it can recreate the objects and hook up the events. Since you have
it off, it says "oh, there's an event for ctl0_grid1_row3 _lnkButton" but
that control doesn't exist, hence the event doesn't get raised..
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
<sr*****@mailci ty.com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com... Thanks for the reply. It works when I enable the viewstate. Not sure how are the two connected? Thanks, Sam. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ashish Shridharan |
last post by:
Hi All
I have been trying to add a control to the header cell of
a datagrid on my ASP.NET page. These controls are defined
in the HTML as ASP.NET web controls.
They are being added into the header of the datagrid in
the "ItemDataBound" method of the grid. However, once,
they are added in the grid, i seem to lose the event
handler for the same control. Is there anyone who has
tried this before and knows why this is hapenning ??
|
by: Mark |
last post by:
I have two buttons in a DataGrid. If I leave the ButtonType = "LinkButton",
the EditCommand and DeleteCommand events fire fine. If I change th
ButtonType = "PushButton", the events do not fire. Does this buttonType
property change how the events fire? Suggestions? I have the ItemCommand
event wired up to, but that only fires for the LinkButton as well.
A few code samples below ...
Thanks!
|
by: Nick Gilbert |
last post by:
We have a Datagrid which contains a template column with a button in it,
as well as an actual button column. If either of the buttons are
clicked, the ItemCommand event does not fire.
If however, the ButtonType of the ButtonColumn is changed to
"LinkButton" instead of "PushButton", the event fires normally!
Why on earth is this happening? I presume this a bug in .NET? (We are
using 1.1 final).
|
by: Solomon Shaffer |
last post by:
I am trying to add some link buttons to a datagrid template column at
runtime and trying to wire these buttons up to the ItemCommand event (or any
event when clicked!). The ItemCommand event works fine if I add the controls
at design time in the HTML, but does not seem to catch when I add the
control dynamically in the code behind. The datagrid renders just fine, just
no ItemCommand event... I have included some code snipplets below. Any...
|
by: andla |
last post by:
Hi,
How does events fire in a datagrid.
I know about the problem if turning the viewstate off the events wil
not fire properly even if I rebind the control in every postback. S
then I started to think how does .Net do it if I turn the viewstat
on.
If you use the Request.Form then you can get all the controls tha
| |
by: Daniel Walzenbach |
last post by:
Hi,
I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchTopQuestionsAboutASPNETDataGridServerControl.asp, Selecting Rows by Clicking Anywhere).
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
|
by: charliewest |
last post by:
I am dynamically creating my datagrid, building each column in real-time via
code-behind (using c#).
The only way i have read to add ImageButtons to my grid dynamically is by
creating a separate template class. However, a class cannot create server
controls (or at least this is beyond me).
I am able to create HTML <INPUT> form elements, however, these are not wired
to my datagrid and hence, when clicked do not fire the datagrid's...
|
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 missing here, but after 2 days I am
ready to explode ! Please help.
To create the Delete button I selected the grid in design view,
clicked the "Columns" property and added the Delete button in the
|
by: kevin |
last post by:
Hi, I'm working with VS 2005 and Framework 2.0
I have a datagrid with a link and the selectedindexchanged will not
fire. The page posts back but does nothing.
Protected Sub DataGrid1_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
DataGrid1.SelectedIndexChanged
Label2.Text = "what the H"
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |