473,471 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Create 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.Attributes.Add("onclick","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 2346
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_Anime" <Ju********@discussions.microsoft.com> wrote in message
news:DC**********************************@microsof t.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.Attributes.Add("onclick","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_ItemCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
if (e.CommandName == "DETAIL")
{
AddList.SelectedIndex = e.Item.ItemIndex;
Label2.Text =
((Label)AddList.SelectedItem.FindControl("Label1") ).Text.ToString();
//Server.Transfer ( "StaffDetails.aspx" );
StringBuilder url = new StringBuilder ( );
url.Append ( "StaffDetails.aspx?" );
url.Append ( "&Name=" );
url.Append ( Server.UrlEncode ( Label2.Text ) );
//OpenPopUp(AddList.SelectedItem, url.ToString());
Response.Write("<script language=Javascript>window.open('" + url.ToString()
+ "','StaffDetails', 'width=600, height=200');</script>");
}
}

If anyone has a better solution I would be interested to know.
"Jules_Anime" 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.Attributes.Add("onclick","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
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...
3
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...
4
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 =...
4
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...
6
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...
0
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...
1
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"...
3
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...
3
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...
0
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...
1
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...
0
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...
0
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,...
1
isladogs
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
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.