473,396 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DataGrid onClick

Hi,

I need to create the following ...

I have DataGrid filled with information (ID, name, price ...).
I need to call a function when I click on the item in the DataGrid (and pass
ID as an argument to that function). I tried to add DataGrid_ItemDataBound
function, but I can't add Command and CommandArgument properties to each
DataGrid Item.
Thanx, Neven
Nov 19 '05 #1
4 4762
Check out this article,
http://www.microsoft.com/india/msdn/...0DataGrid.aspx

--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"Neven Klofutar" <neven.klofutar*r.e..mo*****@vip.hr> wrote in message
news:ek**************@TK2MSFTNGP09.phx.gbl...
Hi,

I need to create the following ...

I have DataGrid filled with information (ID, name, price ...).
I need to call a function when I click on the item in the DataGrid (and pass ID as an argument to that function). I tried to add DataGrid_ItemDataBound
function, but I can't add Command and CommandArgument properties to each
DataGrid Item.
Thanx, Neven

Nov 19 '05 #2
Neven,

Is the function on the client or server side?

If it is on the client, or even if it is on server, but you want to do
something on the client, for example highlighting the selected row, you can
take the following way.

Setup client side onclick event for items like in the following snippet:

private void dg_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType itemType = e.Item.ItemType;
if ((itemType == ListItemType.Pager) ||
(itemType == ListItemType.Header) ||
(itemType == ListItemType.Footer))
return;
e.Item.Attributes["onclick"] = "onSelectRowClick(this)";
}

Client side function onSelectRowClick accepts a reference to the row. This
makes all cell values available on client side. Now, if you need to pass one
of them back to the server you can do it in one of several ways of passing
form data from client to server.

Eliyahu

"Neven Klofutar" <neven.klofutar*r.e..mo*****@vip.hr> wrote in message
news:ek****************@TK2MSFTNGP09.phx.gbl...
Hi,

I need to create the following ...

I have DataGrid filled with information (ID, name, price ...).
I need to call a function when I click on the item in the DataGrid (and pass ID as an argument to that function). I tried to add DataGrid_ItemDataBound
function, but I can't add Command and CommandArgument properties to each
DataGrid Item.
Thanx, Neven

Nov 19 '05 #3
I need to call server side function in order to put item in session object,
something like buying on online shop.

Thanx, Neven
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:uE**************@TK2MSFTNGP12.phx.gbl...
Neven,

Is the function on the client or server side?

If it is on the client, or even if it is on server, but you want to do
something on the client, for example highlighting the selected row, you can take the following way.

Setup client side onclick event for items like in the following snippet:

private void dg_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType itemType = e.Item.ItemType;
if ((itemType == ListItemType.Pager) ||
(itemType == ListItemType.Header) ||
(itemType == ListItemType.Footer))
return;
e.Item.Attributes["onclick"] = "onSelectRowClick(this)";
}

Client side function onSelectRowClick accepts a reference to the row. This
makes all cell values available on client side. Now, if you need to pass one of them back to the server you can do it in one of several ways of passing
form data from client to server.

Eliyahu

"Neven Klofutar" <neven.klofutar*r.e..mo*****@vip.hr> wrote in message
news:ek****************@TK2MSFTNGP09.phx.gbl...
Hi,

I need to create the following ...

I have DataGrid filled with information (ID, name, price ...).
I need to call a function when I click on the item in the DataGrid (and

pass
ID as an argument to that function). I tried to add DataGrid_ItemDataBound function, but I can't add Command and CommandArgument properties to each
DataGrid Item.
Thanx, Neven


Nov 19 '05 #4
Thanx, this helped alot.
Problem solved !

Thanx, Neven

"Saravana" <sa******@sct.co.in> wrote in message
news:yc*****************@news.cpqcorp.net...
Check out this article,
http://www.microsoft.com/india/msdn/...0DataGrid.aspx
--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"Neven Klofutar" <neven.klofutar*r.e..mo*****@vip.hr> wrote in message
news:ek**************@TK2MSFTNGP09.phx.gbl...
Hi,

I need to create the following ...

I have DataGrid filled with information (ID, name, price ...).
I need to call a function when I click on the item in the DataGrid (and

pass
ID as an argument to that function). I tried to add DataGrid_ItemDataBound function, but I can't add Command and CommandArgument properties to each
DataGrid Item.
Thanx, Neven


Nov 19 '05 #5

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

Similar topics

3
by: vinayak | last post by:
Hi I am displaying data in Datagrid in ASP.NET with Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to server. These button controls...
8
by: Sue | last post by:
I have a datagrid populated with 6 visible read-only labels and several hidden fields. Below the datagrid, I have a table with various textboxes, dropdowns, etc. I've managed to decypher the...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
2
by: Daniel Walzenbach | last post by:
Hi, I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to...
4
by: News | last post by:
I have a page with many controls. Among these controls there is a table which is a datagrid with nested repeater inside. My problem is that I can not use DataGridCommandEventArgs to get datagrid...
19
by: Sjaakie Helderhorst | last post by:
Hello, I need to add a Javascript event (onClick) to a servercontrol (asp:checkbox). Checkbox is named 'cbDoMail'. Assumed that 'cbDoMail.Attributes.Add("onClick", "doJavascriptThing()") would do...
2
by: karunakar | last post by:
Hi All In datagrid OnMouseOver iam showing some color Onmouseout also working fine . Here my problem is when ever click the pariculat row in DataGrid iam showing red color that time i am not...
0
by: SergioT | last post by:
Hi I need to call a function when an image iss clicked andt send 2 parameters , the name of the control that indicate the item ID and the name of the control that have the item's Description I...
0
by: Wyatt70 | last post by:
I'm attempting to implement a javascript popup calendar in a DataGrid. The calendar will be used to insert a date into a textbox. I keep getting a "System.NullReferenceException: Object reference...
7
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...
0
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...
0
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...

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.