473,396 Members | 1,938 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.

Gridview - is individual cell click event possible?

K B
I would like to create a gridview as below:

Project Name 1-1 1-2 1-3 1-4 1-5 1-6
Project 1 BLUE BLUE BLUE BLUE GREEN GREEN
more projects

I would like to fill the cell with a solid color based on the value of
the cell (e.g., documents that are complete (blue) or not complete
(green). In effect have a solid bar indicator going across each row. I
know how to color the cell based on the value, but not the click part.

Is there any way to do this so that I can then get row/cell information
based on the CELL clicked? I will need to retrieve the column title and
value of the cell as well as the first column value.

Any direction GREATLY appreciated!

Thanks,
Kit

*** Sent via Developersdex http://www.developersdex.com ***
Mar 8 '07 #1
1 27438
You can do it easily with a bit of javascripting.

Make 3 hidden fields:
<input runat=server type=hidden id=inhAction />
<input runat=server type=hidden id=inhRow />
<input runat=server type=hidden id=inhColumn />

and a javascript function:
function cellClicked(row, column){
myForm.inhAction.value = "CELLCLICKED";
myForm.inhRow.value = row;
myForm.inhColumn.value = column;
myForm.submit();
}

and in the gridview's RowDataBound event setup the javascript call for every
cell:
myCell.Attributes["onclick"]=String.Format("cellClicked({0},{1})",
myCellRow, myCellColumn);

When you click a cell, you will get a postback. You can tell taht the
postback is caused by a cell click by looking in the inhAction and you can
get the row and the column numbers from the inhRow and inhColumn.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"K B" <ka**********@comcast.netwrote in message
news:OM**************@TK2MSFTNGP02.phx.gbl...
>I would like to create a gridview as below:

Project Name 1-1 1-2 1-3 1-4 1-5 1-6
Project 1 BLUE BLUE BLUE BLUE GREEN GREEN
more projects

I would like to fill the cell with a solid color based on the value of
the cell (e.g., documents that are complete (blue) or not complete
(green). In effect have a solid bar indicator going across each row. I
know how to color the cell based on the value, but not the click part.

Is there any way to do this so that I can then get row/cell information
based on the CELL clicked? I will need to retrieve the column title and
value of the cell as well as the first column value.

Any direction GREATLY appreciated!

Thanks,
Kit

*** Sent via Developersdex http://www.developersdex.com ***

Mar 8 '07 #2

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

Similar topics

2
by: Carl Gilbert | last post by:
Hi I have a basic page for which I have included some of the code for at the end of this message. It may not run correctly as I have cropped out a lot of code. I am trying to handle the...
1
by: andrewcw | last post by:
The clcik event on the ListView control seems to trigger off the item level ( the first column ). I would like to be able to trap the click event on a particular subitem ( a specific column's row...
1
by: Lonewolf | last post by:
hi all, just want to find out if it is possible to set the gridline of individual cell in a listview using C#. Reason for this is I need to have a listview which has fixed number of columns and...
1
by: jonathanmcdougall | last post by:
I am developing a calendar on which dates can be clicked and selected. A calendar is a table in which each day is a cell. Each cell has a unique id. By left-clicking on a date, it gets selected...
0
by: Riaaaa | last post by:
I have created the form for entering the company details with its general information in asp.net C# 2005. I have two buttons that form on the submit click event it should saw the newly / last...
0
by: ajanu81 | last post by:
hi all, i am new to this forum. i am using a windows application using C#. I am using a datagridview to display contents of a xml file. say i have a xml file like this. <xml version="1.0"...
0
by: ADN | last post by:
Hi, I am currently extending the GridView control and would like to add a button to the GridView so that it will automatically render one button at the top of the grid. I have a click event for...
1
by: ADN | last post by:
Hi, I am currently extending the GridView control and would like to add a button to the GridView so that it will automatically render one button at the top of the grid. I have a click event for...
4
by: vineetbindal | last post by:
Hi all, I have a gridview, when onselectedindexchanged in fired. i want to convert the selected row's column's into dropdown so that user can select the new value and update it. please tell me...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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...

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.