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...