473,804 Members | 2,184 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

gridView row selected

Hi,

I use GridView control in asp.net.
I would like to write an event on the client site. When somebody click on
row, I would like to clear all selected rows in GridView and changed cliked
row color in permanent way.
How to do it in JavaScript ?

Thank you for help

Oct 21 '08 #1
1 5646
On Oct 21, 3:47*pm, "imbirek8" <imbir...@op.pl wrote:
Hi,

I use GridView control in asp.net.
I would like to write an event on the client site. When somebody click on
row, I would like to clear all selected rows in GridView and changed cliked
row color in permanent way.
How to do it in JavaScript ?

Thank you for help
Yes it is possible. ASP.NET grid view is nothing but HTML table at
client side.
You have to write some script to bind all events to the grid (i.e.
HTML table) once body load complete. Like on body load

function onbodyload()
{
var oGrd = docuement.getEl ementById("grid view name");//grid name
some time changes if you are using master page or user control.
//You could do same thing at grid click level but again you have to
play with srcElement of IE or //target for Moz as well as nodeName
for(var i = 0; i < oGrd.rows.lengt h; i++)
{
oGrd.rows[i].onclick = onrowclick;//Bind the click event for each
row
if(i % 2 == 0)//setting row color alternate
oGrd.rows[i].style.backgrou ndColor = "green";
else
oGrd.rows[i].style.backgrou ndColor = "yellow";

}
}

function onrowclick(oRow )
{
alert(oRow.rowI ndex);
}
please check this and if it is working fine then easily you can delete
row. Other wise I will help you.
Oct 21 '08 #2

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

Similar topics

2
2735
by: NH | last post by:
How can I set the selected item in a dropdownlist which is declared in the edititemtemlpate of a gridview? Which gridview event should I use, I cant seem to figure it out...
5
7834
by: mosscliffe | last post by:
Following Mr Tabors Video on Databinding I implemented the following code In GridViewSelectedIndexChange I coded DetailsView1.pageindex = gridview1.selectedindex This works fine for the first page of the binding, but once thr gridview re-arranges - the formview only ever sees in effect the rowdisplayedindex
0
3737
by: Child X | last post by:
Hi all, I have a web form with two GridViews on it. GridView 'A' populates GridView 'B' based on it 'SelectedRowValue'. What i am after, is ...if someone delete a row from grid 'A' and it is currently the 'SelectedRow'... I want to decrement GridViews selected index by 1 so it falls to the
0
999
by: CK | last post by:
Hi All, I have a gridview that contains a column that has a repeater inside it. My intent is to put every comment for an album into the repeater in the comments column. I am using a SQLDataSource with a control parameter. The parameter value is the outer gridview selected value. This of course onlys gets the comments for the selected row. Can I use a property on like the row databound event and get the datakey of the current row to use as...
2
12526
by: Kirk | last post by:
I have a GridView that displays several columns, one of which is a checkbox field. This is populated at runtime from a SqlDataSource and is not enabled (the user can't change it's value). I have turned on the "Enable Selection" option, and I know I can identify what is the currently selected row. How can I get the value of the checkbox in the selected row? For columns that are just text, this works:
1
1733
by: shapper | last post by:
Hello, I have a two elements on my page: a GridView and form that has various controls (textboxes, dropdownlists, etc) When I click a GridView row I need to fill the form controls. I will use visible and invisible columns in the gridview selected row. Then I when I click the button of the form I am submitting the form values but there are also a few values which I don't want to show in
1
5044
by: Dinu | last post by:
hi i am having a gridview in aspx page and a usercontrol in master page of that page now what i want is selected row text to be displayed in usercontrol i wrote code as follows: Protected Sub gvwServices_SelectedIndexChanged(ByVal sender As Object,
1
1428
by: DAnDA | last post by:
Hey i binding gridview/formview using one sqlDataSource,, that mean formview show all details from gridview selected row,,, now i cant use paging property for formview ,,, can anyone show me how to use paging formview ?!
1
4351
by: Sobin Thomas | last post by:
Hi All....... I am a beginner in asp.net. How can I call a javascript function on the selected index change of Gridview ,in asp.net? Can you help me with sample code? Thanks in advance....
0
2131
by: perumalsamy R | last post by:
I am using gridview in my project.When i am clicking the checkbox ,I want to add the price value on gridview selected index changed event.can you help for my problem please help me?
0
10595
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...
1
10341
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10089
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...
0
9171
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6862
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
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
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
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.