473,804 Members | 3,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Button event in DataList

I have a Button in a DataList Footer. I add the click event like this:

void Item_DataBound( Object sender, DataListItemEve ntArgs e)
{
if(e.Item.ItemT ype == ListItemType.Fo oter)
{
Button ctlSave = (Button)e.Item. FindControl("ct lSave");
ctlSave.Click += new EventHandler(ct lSave_Click);
}
}

It seems that the ctlSave_Click method is never called though. Am I doing
this right?
Nov 18 '05 #1
1 1707
Hi,

you'd need to wire this event in ItemCreated. I don't think the code ever
reaches Footer in ItemDataBound as footer isn't bindable item by default. In
ItemCreated Footer is always accessed (Footer item created), so that way it
should work.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"David W. Simmonds" <da***@simmonds .ca> wrote in message
news:PVuZb.5803 43$ts4.375490@p d7tw3no...
I have a Button in a DataList Footer. I add the click event like this:

void Item_DataBound( Object sender, DataListItemEve ntArgs e)
{
if(e.Item.ItemT ype == ListItemType.Fo oter)
{
Button ctlSave = (Button)e.Item. FindControl("ct lSave");
ctlSave.Click += new EventHandler(ct lSave_Click);
}
}

It seems that the ctlSave_Click method is never called though. Am I doing
this right?

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
14333
by: Chris Fink | last post by:
Hello, I have a datalist that contains an asp button. I have the need to pass a value that is bound to my datalist along the button when the on_click event is fired. My datalist creates a button for each row in my datasource, so each button needs to pass a unique value. My questions are: 1. How do I pass the value with the button without making it visible on the button or form. 2. Is there a way to grab this value in the button's...
3
2762
by: moondaddy | last post by:
using vb.net 1.1 I have a datalist and in it's item template I have 2 buttons, 'edit' and 'ShipToThisAddress'. The edit button works fine and it opens up the edit template as it works with the edit command. But the how do I wire ShipToThisAddress button? Its going to submit the address ID to the database and do a redirect to another page. In the process of doing this, it will need to get the row index in the datalist so I can get the...
3
1737
by: Chris | last post by:
Hi Folks, well I have this "small" problem with the footertemplate in a datalist. I added a button and a textbox to update the db with the given String of the Textbox. I already searched for it and know now, that I have to place the handling in Itemcreated. So when I click on the button everything is fine except when the sub "createSubject" is called, then I get an "Object reference not set" error.
2
8739
by: Chris Fink | last post by:
This should be relatively simple but I am unable to find an asp:button tag in a datalist footer. I have tried it numerous ways including the FindControl method from the many events that the DataList exposes and the result is always null (I've determined the OnItemDataBound event will not find the footer controls). I understand that I have to navigate the datalist object tree, but I feel like it is a guessing game and am hesitant to do it...
0
1656
by: manu_srinivasa | last post by:
:( Here is my design, we have user control placed in a aspx page. within user control, i am having datalist, within datalist i am placing radio button. On click of radio button, i need to know the seleceted row of the datalist. radiobutton checkchanged event is not firing.
3
4312
by: Patrick Olurotimi Ige | last post by:
Can i have a Button in a Datalist? The button is for posting a form to the the Database FOr example:- <ASP:DataList id="heading0" RepeatLayout="Flow" RepeatDirection="Horizontal" runat="server"> <ItemTemplate> <asp:button id="cmdSubmit1" class="button" text=<%#DataBinder.Eval(Container.DataItem, "headerDescription") %> OnClick="formUpdate" runat="server"/> </itemTemplate>
1
2243
by: Pavan | last post by:
Hi All, I have created a custom DataList web custom control, which populates data from a dataset. This dataset is available at runtime and exposed as property by my custom control. During preRender event of custom control, i populate Column Headers, Item Data from the DataSet using CustomTemplate class for my inner DataList
16
12153
by: Vikas Kumar | last post by:
i am selectin some data from database and through reader showing it in datalist as above now for radio buttons i have single column which returns 1,2,3 and according to that i want one of above radio button to be preselected in this datalist how can i do that doing something like this but this gives error "The type or namespace name 'rdbtn' could not be found (are you missing a using directive or an assembly reference?)" as its in datalist
0
1285
by: pavankumar106 | last post by:
Hi im stuck in sm simple pb ..im having a datalist in wich im having images and each image have a delete button below it.now wen I press delete button I shud be able to delete that image in dataset and bind it to datalist.i ve tried to run the code in button click event of delete,button command click event and also datalist delete command event.But its not gng to break point at all.. Can u say da reason y its not firing..:) n can anyone tell me...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9582
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,...
0
10082
tracyyun
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...
0
9157
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
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...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
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
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.