473,788 Members | 2,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 27503
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.inhActio n.value = "CELLCLICKE D";
myForm.inhRow.v alue = row;
myForm.inhColum n.value = column;
myForm.submit() ;
}

and in the gridview's RowDataBound event setup the javascript call for every
cell:
myCell.Attribut es["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**********@c omcast.netwrote in message
news:OM******** ******@TK2MSFTN GP02.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
2885
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 click event for a cell. From the code you should be able to see that I am handling the mouse over event and would like to link to another page via the cell click.
1
23714
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 ). If possible, what do I do to activate that 'cell' - thanks. I thought that listView.LabelEdit = true; would enable me to navigate into the cells or something like listView.items .subitems.LabelEdit - but I did not see such a property....
1
3099
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 rows, but individual cell can span columns, though not row. As such, I need to be able to set the gridline of individual cell, something like how u set the table grid for individual cell in MS Word's table. I don't know what event in the custom...
1
3545
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 (with a blue background). By then shift-left-clicking on another date, the range between the first and second dates gets selected. This is a behavior commonly found on GUI widgets. Therefore, I need to cancel the onMouseDown event so the browser...
0
1370
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 entered record in the database. view click event it should saw me all the details except the id of the company. The data is displayed in the gridview. How should i pass this ?? <asp:GridView ID="CompanyGridView" runat="server"...
0
1512
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" encoding="UTF-8"> <maincategory> <cat1> <title>Category1</title>
0
2902
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 that button, but everytime the button is clicked, the page posts back and the click event does not fire (probably because the button gets created every single time there's a postback). What is the best way for me to create this button and then...
1
2867
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 that button, but everytime the button is clicked, the page posts back and the click event does not fire (probably because the button gets created every single time there's a postback). What is the best way for me to create
4
3902
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 how can i do that? regards, Vineet
0
9656
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
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10364
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...
0
10172
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9967
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...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
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

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.