To get the row index of selected row in grid view

Hi I have a grid view with a column of checkboxes. if I check a checkbox all the remaining checkboxes should be unchecked except the current one.

protected void chkHeadCoach_CheckedChanged(object sender, EventArgs e)

{

foreach (GridViewRow rowitem in grdv.Rows)

{

CheckBox chkHeadCoach = (CheckBox)(rowitem.FindControl("chkHeadCoach"));if (chkHeadCoach.Checked)

{

if(rowitem.RowIndex != //row index of the row I checked now)

{

chkHeadCoach.Checked =
false;

}

}

}

how can I get the row index of the row I checked now?

}


Thanks & Regards,
Abhiram Reddy Mekha.
0
AbhiramReddyMekha
12/2/2008 10:16:04 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

3 Replies
1439 Views

Similar Articles

[PageSpeed] 33

AbhiramReddyMekha:
how can I get the row index of the row I checked now?

If you are creating  CheckedChanged event of checkbox on rowcreated event of gridview, then you can set RowIndex in any property of checkbox which return type is string such like as tooltip.So you can easily get rowindex in CheckedChanged by getting tooltip of checkbox.

May I know what is your actual requirement?

Regard

Imrankhan


Imrankhan
-----------------------------------------------------
Always remember to mark as answer on the post that helped you.

My Blog :
http://aspnet-solutions.blogspot.com/
http://javascriptsolution.blogspot.com/
0
imran_khan
12/2/2008 12:10:44 PM
protected void chkHeadCoach_CheckedChanged(object sender, EventArgs e) 

{

GridViewRow datarow = (GridViewRow)(((Control)sender).NamingContainer);

int i = datarow.RowIndex;

foreach (GridViewRow rowitem in grdv.Rows)

{

CheckBox chkHeadCoach = (CheckBox)(rowitem.FindControl("chkHeadCoach")); if (rowitem.RowIndex == i)

{

chkHeadCoach.Checked =
true;

}

else

{

chkHeadCoach.Checked =
false;

}

}

}

This is the solution and I got it.

Can any one tell me how I can do the same using java script?


Thanks & Regards,
Abhiram Reddy Mekha.
0
AbhiramReddyMekha
12/2/2008 1:01:11 PM

Hi AbhiramReddyMekha,

Have a look at the sample in this link, and you will find the answer.

http://aspdotnetcodebook.blogspot.com/2008/08/how-to-add-mutually-exclusive-checkbox.html

Thanks,


Qin Dian Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Qin
12/4/2008 10:02:14 AM
Reply:

Similar Artilces:

How to get the row index of a selected row in listview control
Can someone please tell me how to get the index of a selected row in a listview.  <ItemTemplate> <asp:LinkButton runat="server" class="linkButton" id="xxxxx" Text='<%#Eval("documenttype") %>' CommandName="OpenFile" CommandArgument='<%#Eval("DocumentKey") %>'></asp:LinkButton></ItemTemplate>what you have to do is, in itemcommand event of ListView, you have to get the value of row indexif(e.CommandName == "corrospondingcommaandname"){     &nb...

how can i get index of row in grid by clicking on grid row
how can i get index of row in grid by clicking on grid row Hi there,Under the selectedindexchanged event of the gridview put this:protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { int index= GridView1.SelectedIndex;//to get the indexGridViewRow row= GridView1.SelectedRow; //to get the selected row} thanks,Murthy Dont forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped. Once you get the index of the row, how do ...

How to get grid view row index .......
i have grid view. One of the columns contain radio buttons only. i want to handle the check changed event of the radio button. i m coding for it. every radio button has the same ID as they are created at runtime using a template field. Can i know the grid view row index whose radio button is checked/unchecked while handling the event? Please help! Like this: protected void RadioButton1_CheckedChanged(object sender, EventArgs e) { RadioButton rad = sender as RadioButton; GridViewRow row = rad.NamingContainer as GridViewRow; int rowIndex = row.RowIndex; }Thanks, EdMicroso...

How to get selected rows from Grid View
Hi Friends, I hava a ASP.NET gird view which is progrmatically populated by using a dataset. I need to get only the selected values (sub set of the initial data set which used to populate the GridView). I added a CheckBox as an ItemTemplate. Please help me to do this task.Best Regards./GKT Hi, what do you mean only the selected values? Write some code in order to describe how the gridview looks like.  Where is your checkbox - in which column? Type some code please (of the .aspx source and .cs file) Hi, This is a code segment for GridView. <asp:GridView ID="grdClients&quo...

On selecting a row from a grid view
Hi I'm hoping someone can help me out. I've got a simple grid view where I've enabled the 'select' option. When the user clicks select, I would like a row of data to be written to the database. For now I'm hard codeing the data written, but once I've got it working I'd like to pass some of the values from the line selected - one step at a time! The code I've put togeather from various google searches doesn't through any errors - but it also doesn't add any values to the DB. Any thoughts???? Thanks in advance. Imports System.Data.SqlClient Impo...

how to update selected row in Grid View Control?
Hello friends! I am a newbie with asp and i am having difficulty..   how can i create a Grid View Control that have select button on each row...? when i click the control, a popup window opens displaying the selected row, which i can update my record... when i click a submit button, the popup window closes then updates, the parent window..   explanation with sample code is greatly appreciated.. from my understanding, in GridView you have a property to automatically include select button with this property: AutoGenerateSelectButton = trueFor identifying selected row, using t...

Get velue from the selected row in grid view
Dear all,I use vb.net 2008 could you please tell me how to get the value from the selected row in the gridview and put to a textbox?also how to make the color of selected row is change and how to select multiple row? Thank you,Hanars  Hi For value you should use Textbox.Text = GridView.SelectedValue in the code behind using the Prerender Event of the TextBox You should define this value in DataKeyNames though. For coloring you could use OnRowDataBound. The e Argument will give you all the values of the row:Public Sub define_color_bck(ByVal Sender As Object, ByVal e As Gri...

How to delete row from GridView control
Hello,  I am working on an ASP.NET 2.0 app, and I am trying to wire up a "Delete" button to a gridview control on a form. Here is the code for the ASP :  <asp:GridView ID="gvInConditions" runat="server" AutoGenerateColumns="true" OnRowDeleting="gvInConditions_RowDeleting" DataKeyNames="Condition_ID" >         <Columns>                <asp:CommandField ButtonType="Button" SelectText=&...

Get the index of selected columns and rows in grid DW
Hello! Is it possible to evaluate the row and column number in grid DW which user has selected? Thanks in advance, Vladimir Kolykhalov Vlad; Check the arguments on many of the DW Control events. The Row and column (DWO pointer) are given. Also, at any time you can use the GetRow ( ) and GetColumn ( ) methods. regards ... Chris "Vladimir A. Kolykhalov" <kolykhalov@yandexDOTru> wrote in message news:414818c3$1@forums-2-dub... > Hello! > > Is it possible to evaluate the row and column number in grid DW which user > has selected? > ...

How Do a get a columnID value from Grid View Selected row
Hello All Asp gurus, Am a newbie. How do I get a ColumnID value from a GridView List, I want to get the file ID and call update or delete function using click buttons I have tried this line but is not working on me Dim ColItem As String ColItem= GridView1.DataKeyNames(GridView1.SelectedIndex).Values("ChannelID").ToString Please help   Try this: 1 <asp:GridView ID="GridView1" runat="server" 2 DataKeyNames="ChannelID" />   1 If GridView1.SelectedIndex >= 0 Then 2 Dim id As String = GridView1.Da...

How to set the row number and get the row number for ("selected row) in Datagrid
I face a problem that i can't get the selected row of the datagrid in both server side script (VB.net) and client side script (javascript) As i can't use the button column / hyperlink column in the datagrid. Thus , i need to handle the change the background color of the selected row and also to get the selected row number for Update/Delete. Thanks in advance. This depends on how do you perform the selection. Do you want to implement chaning of the SelectedRow at the client side without any postback? If you have no issues with postback, then you can do s little trick here: 1. ...

select row grid with arrow key (up&down) and get datakey this row whit enter key
hi friends how i can select row grid with arrow key (up&down) and get datakey this row whit enter key but that in client side code plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz  help me thanks a lot     this article talks about how to bind keyboard shortcut to Click event of the botton http://www.vikramlakhotia.com/Binding_keyboard_shortcut_in_AspNet.aspx also this article discusses the same http://forums.asp.net/p/1119365/1748317.aspx#1748317Vikram www.vikramlakhotia.comPlease mark the answer if it helped you hi vik20000in  tanks a ...

How to get selected index of dropdownlistboxs present in two different rows of gridview
I have a gridview, in that i have dropdownlistbox as one column.  Without editing the grid view i want to know the selected index of dropdownlistbox for each row. See http://forums.asp.net/t/1170088.aspx.Thanks, EdMicrosoft MVP - ASP/ASP.NET...

How to get selected index of dropdownlistboxs present in two different rows of gridview
I have a gridview, in that i have dropdownlistbox as one column. Without editing the grid view i want to know the selected index of dropdownlistbox for each row. Simply itearte through the Rows collection of your GridView. Then, use the FindControl method of the GridViewRow reference and retrieve a reference to your DropDownList. From here, you can then retrieve your SelectedIndex. This can be done within the GridView.DataBound event or later.Thanks, EdMicrosoft MVP - ASP/ASP.NET...

Web resources about - To get the row index of selected row in grid view - asp.net.presentation-controls

Portal:Bollywood/Selected biography - Wikipedia, the free encyclopedia
Write three or four paragraphs in the text field using information from the selected notable article, you may find it useful to examine the existing ...

F8: Facebook’s FbStart Initiative Will Give Selected Developers A $30K Kick-Start
... successful applications is likely a whole lot easier with $30,000 in free tools and services to start off with, and that’s exactly what selected ...

LEGO Shop - The LEGO Technic team has selected the winner... - Facebook
The LEGO Technic team has selected the winner of the Co-Creation Challenge! LEGO will be producing a limited run of 20,000 of this stunning set.... ...

Grand Doctor Ma Selected Students-baby365 on the App Store on iTunes
Get Grand Doctor Ma Selected Students-baby365 on the App Store. See screenshots and ratings, and read customer reviews.

Selected Cheney Vice Presidential Photographs
... for photos found within these albums are Paul Morse, Karen Ballard, Kimberlee Hewitt, Shealah Craighead, and Chris Greenberg. These selected ...

[iOS Advice] How To Clarify Your Email Replies By Quoting Selected Text - YouTube
Follow me on Twitter: http://www.twitter.com/macmixing Like my Facebook page: http://www.facebook.com/macmixing RATE, COMMENT, SUBSCRIBE! :-) ...

UAE Under-19 cricketers for ACC Premier League tour of Malaysia selected - The National
Coach Aaqib Javed seeking fresh blood for senior team after missing out on World Twenty20

Animal of the Day: Lucius Has Been Selected as the U.K.’s ‘Happiest Cat’
He’s got one blue eye, one green eye and a heart of gold. British mobile phone company O2 recently held some “cat auditions” to find “the UK’s ...

Boyd Cordner selected for Kangaroos squad
Sydney Roosters stars Michael Jennings and Boyd Cordner have capped a grand-final win with selection in the Australian squad for the World Cup ...

Redlands LNP branch blood-letting after Matt McEachan pre-selected
There was more blood-letting in the seat of Redlands on the weekend when a motorcycle instructor was named LNP candidate for the embattled electorate ...

Resources last updated: 12/15/2015 1:39:48 PM