473,795 Members | 2,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Button In Datalist?

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="F low"
RepeatDirection ="Horizontal " runat="server">
<ItemTemplate >
<asp:button id="cmdSubmit1 " class="button"
text=<%#DataBin der.Eval(Contai ner.DataItem, "headerDescript ion") %>
OnClick="formUp date" runat="server"/>
</itemTemplate>
</asp:datalist>
But its not firing?
Any ideas?


*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #1
3 4311
Yes you can use a Button in a DataList and handle events as you've decribed.
I'm not quite sure why your code snippet isn't working (I don't know what
the codebehind looks like). Another idea for handling events on the Button
in the DataList is to handle the DataList's ItemCommand event. With ItemCommand,
the DataListCommand EventArgs tells you which item in the DataList contained
the button.

-Brock
DevelopMentor
http://staff.develop.com/ballen
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="F low"
RepeatDirection ="Horizontal " runat="server">
<ItemTemplate >
<asp:button id="cmdSubmit1 " class="button"
text=<%#DataBin der.Eval(Contai ner.DataItem, "headerDescript ion") %>
OnClick="formUp date" runat="server"/>
</itemTemplate>
</asp:datalist>
But its not firing?
Any ideas?
*** Sent via Developersdex http://www.developersdex.com ***


Nov 19 '05 #2
Thx Brock for the reply..
The code is below
What am i missing?

-------------------------------
Sub FormUpDate(ByVa l sender As Object, ByVal e As
DataListCommand EventArgs) Handles DataList1.ItemC ommand

If e.CommandName = "UpDate" Then
Response.Write( "test")

End If

End Sub

<asp:DataList Runat="server" EnableViewState ="True" ID="DataList1"
OnItemCommand=" FormUpDate">
<ItemTemplate >

<asp:Button id="cmdSubmit" text="Save" runat="server"
CommandName="Up Date"/>
</ItemTemplate>
</asp:DataList>


*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #3
That code below looks fine except you have the event wired up twice. You
only need one of the Handles keyword in the VB.NET code or the OnItemCommand
in the ASPX code. Having both will cause the event to be fired twice.

As for the reason the event isn't firing, are you databinding upon every
postback in Page_Load? You should only DataBind when IsPostBack = false,
or, IOW, the first access to the page.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Thx Brock for the reply..
The code is below
What am i missing?
-------------------------------
Sub FormUpDate(ByVa l sender As Object, ByVal e As
DataListCommand EventArgs) Handles DataList1.ItemC ommand
If e.CommandName = "UpDate" Then
Response.Write( "test")
End If

End Sub

<asp:DataList Runat="server" EnableViewState ="True" ID="DataList1"
OnItemCommand=" FormUpDate">
<ItemTemplate >
<asp:Button id="cmdSubmit" text="Save" runat="server"
CommandName="Up Date"/>
</ItemTemplate>
</asp:DataList>
*** Sent via Developersdex http://www.developersdex.com ***


Nov 19 '05 #4

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

Similar topics

2
14332
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
2529
by: Hartmut Schroth | last post by:
Hi, I need a solution for the following problem: In the item template of a datalist control I have already a button control with the commandname set to "select" to perform some specific database action. I additionally want to update an integer value in the underlying data source by simply clicking an a check box or an imagebutton WITHOUT USING THE EDIT/UPDATE COMMANDNAME property of the
2
2472
by: Manish Naik | last post by:
Hi, Using ASP.Net, I want to store and retrive documents (Word, excel, etc) from SQL Server 2000 database. I have tried image type data field, but could not succed. Can any one help me please. Regards, Manish Naik
2
8738
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...
3
5949
by: David Hearn | last post by:
I have a datalist that I have inserted a radio button into. The datalist populates with a list of items and each one has a radio button next to it. I need to use the radio button to allow the user to select a default item so when the user clicks one of the radio buttons, it needs to clear the checked property from the rest. This is default behavior for the radio button, but it doesn't work when it is embedded into a datalist. I have tried...
1
1409
by: jagdishl | last post by:
Hi: I have a datalist which is populated dynamically based on a query.I have to place a submit button after datalist (not in the footer template) so that after pressing the submit button a final update is made to the database.The datalist may at times be very long.i was wondering how I could place this submit button in the design page.I would really be grateful if you could point out to sample codes. Thank you. Jagdish.l
2
3450
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: //Page_load of my user control protected void Page_Load(object sender, EventArgs e) { IDataItemContainer DataContainer = this.Parent as
3
2223
by: asadikhan | last post by:
Hi, I am trying to use a datalist to edit data in a MySql database as follows. For now I just want to be able to get the changes to be made on the dataset. Here is my code: using System; using System.Configuration; using System.Collections; using System.ComponentModel;
2
4714
by: Jack | last post by:
Hello, I need to add extra buttons to a datalist, but I don't know to add them to the control. I need to use the onCommand Functions, like OnUpdate, OnEdit, OnUpdate, OnCanel, Etc. I would like to do this VB.Net is that is can be done. Any help would be great, I have been trying to do this for a while and need help. Thanks in advance for any help,
0
9672
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
9519
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
10438
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10214
jinu1996
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...
1
10164
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,...
0
10001
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
6780
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
5437
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...
3
2920
bsmnconsultancy
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...

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.