473,789 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open New Window from DataList Item...

Is it possible to create an onclick event which is attached to individual
datalist items?

I have a Datalist with some details on employees, and when you click on one
we would like to open a new window which will be populated with some more
data on this employee.

The closest I have come is populating the
DataList.Attrib utes.Add("oncli ck","sUrl") with some information but when I
run the code it needs two clicks to open a window, and on the second click
opens the previous employee details...

DataList with two employees: -

Emp1, Emp2

Click on Emp1 - nothing happens although the Attribute is added to the
DataList. On second click I select Emp2 and the app shows details of Emp1.

Help is required...
Nov 23 '05 #1
2 2366
You have two options. You can either force the single click to be client
side which means an event which performs some javascript action or to make
the list autopostback true and force the index changed event to fire, now
you need to get the required action on postback. You could write an onLoad
event for the page when its loaded and open a child window this way.

--
Best Regards

The Inimitable Mr Newbie º¿º
"Jules_Anim e" <Ju********@dis cussions.micros oft.com> wrote in message
news:DC******** *************** ***********@mic rosoft.com...
Is it possible to create an onclick event which is attached to individual
datalist items?

I have a Datalist with some details on employees, and when you click on
one
we would like to open a new window which will be populated with some more
data on this employee.

The closest I have come is populating the
DataList.Attrib utes.Add("oncli ck","sUrl") with some information but when I
run the code it needs two clicks to open a window, and on the second click
opens the previous employee details...

DataList with two employees: -

Emp1, Emp2

Click on Emp1 - nothing happens although the Attribute is added to the
DataList. On second click I select Emp2 and the app shows details of Emp1.

Help is required...

Nov 23 '05 #2
Had a play and managed to get is working okay...although there is a page
refresh which I am going to have to correct.

I added the Response.Write to my on Command call....

private void AddList_ItemCom mand(object source,
System.Web.UI.W ebControls.Data ListCommandEven tArgs e)
{
if (e.CommandName == "DETAIL")
{
AddList.Selecte dIndex = e.Item.ItemInde x;
Label2.Text =
((Label)AddList .SelectedItem.F indControl("Lab el1")).Text.ToS tring();
//Server.Transfer ( "StaffDetails.a spx" );
StringBuilder url = new StringBuilder ( );
url.Append ( "StaffDetails.a spx?" );
url.Append ( "&Name=" );
url.Append ( Server.UrlEncod e ( Label2.Text ) );
//OpenPopUp(AddLi st.SelectedItem , url.ToString()) ;
Response.Write( "<script language=Javasc ript>window.ope n('" + url.ToString()
+ "','StaffDetail s', 'width=600, height=200');</script>");
}
}

If anyone has a better solution I would be interested to know.
"Jules_Anim e" wrote:
Is it possible to create an onclick event which is attached to individual
datalist items?

I have a Datalist with some details on employees, and when you click on one
we would like to open a new window which will be populated with some more
data on this employee.

The closest I have come is populating the
DataList.Attrib utes.Add("oncli ck","sUrl") with some information but when I
run the code it needs two clicks to open a window, and on the second click
opens the previous employee details...

DataList with two employees: -

Emp1, Emp2

Click on Emp1 - nothing happens although the Attribute is added to the
DataList. On second click I select Emp2 and the app shows details of Emp1.

Help is required...

Nov 23 '05 #3

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

Similar topics

1
5326
by: Nevyn Twyll | last post by:
I have a DataList; in the DataList's , I have a LinkButton and a few listboxes. When the LinkButton is pressed, I need to get the ID of the selected item in one of the Listbox controls. Then I want to launch another web page in a seperate window, using that ID. In the header of the web page, I have a javascript function LaunchMyWindow(iID) that launches that window. For a normal LinkButton Control, I could just use
3
4731
by: Hardy Wang | last post by:
Hi all; I have a DataList with ItemCreated event like below: private void myList_ItemCreated(object sender , DataListItemEventArgs e) { DataRowView myRowView; DataRow myRow; if (e.Item.DataItem != null) { Trace.Write(e.Item.ItemType.ToString(), "---with data"); } else { Trace.Write(e.Item.ItemType.ToString(), "---without data"); }
4
8305
by: jenn | last post by:
Hi Anyone knows how to access to a value of a row in a datalist. Something like this in datagrid Dim str = MyDataGrid.Cell(0).tex I would like something like this Dim str = DataBinder.Eval(MyDatalist.Items(count).DataItem, "customerId") but it doesn't work.
4
3097
by: V. Jenks | last post by:
What seems like a simple thing is apparently not so straightforward? I have a datalist. Inside of that datalist is an <itemtemplate> secion which contains other server controls such as a label, a radiobuttonlist, etc. I'm driving myself insane trying to figure out how to get
6
9595
by: Paul | last post by:
I am trying to use a DataList and the ItemTemplate. I am binding the Datalist to a SQL query that gives me a list of Items with a Parent Category. I want to loop through all the items, but only print the Parent Category once, regardless of how many child items are in it. So my perfect output would look something like:
0
2573
by: troutbum | last post by:
I am experiencing problems when one user has a document open through a share pointing to the web site. I use the dsolefile to read the contents of a particular directory and then display them in a datalist. When the next user selects trys to run the page, the page fails and I get a generic error message from the stack trace. I am assuming that the document properties cannot be read when a file is open, but it worked well in asp. ...
1
3163
by: Jules | last post by:
We have a problem setting, actually resetting, the SelectedItemTemplate of a DataList control. Below is the ObjectDataSource and the DataList in .ASPX: <asp:ObjectDataSource ID="mySource" runat="server" SelectMethod="GetStageUsage" TypeName="SomeController"> </asp:ObjectDataSource> <asp:DataList ID="dl" runat="server" DataSourceID="mySource" DataKeyField="ID" OnItemCommand="dl_ItemCommand">
3
8265
by: mroffey | last post by:
Hi everyone, I've been having this problem and I've searched high and low, but I can't seem to find the answer to what is probably a very simple solution. In a nutshell, I have a nested datalist, Parent and Child. In the child datalist, I need to get 1 of the values from the parent datalist. I've included the dataaccess code below, only for completeness.
3
2811
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I need to control the visibility of a textbox based on a dropdown selection in the datalist's edititem template. To do this, I registered a client script block function and attached a client side handler for the dropdownlist's onchange event in the...
0
9666
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
10408
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...
1
10139
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
9983
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
9020
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
5417
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
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
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
3
2909
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.