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.
0
kof2005
9/17/2004 8:49:04 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

4 Replies
1002 Views

Similar Articles

[PageSpeed] 48

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. Add a LinkButton to your DataGrid's template and set its text to an empty string to make it invisible. Set its CommandName to 'select'
2. Add 'onclick' attribute the row to invoke the Click() method of the select LinkButton
Nope this helps
Bug [MCSD]
0
Bug_Bugger
9/17/2004 1:58:42 PM
Thanks for your reply Bug_Bugger.

Thus is it possible to get the selected row no at the client size and sever side
as i need to hightligth the selected row
and also need to get the row no of the selected row
Thus , i can delete/ update the datagid -->dataset--> database.
Thanks
0
kof2005
9/18/2004 4:47:55 AM
Sure, things are simplier if implemented at the server side. 

1. To highlight the selected row all you need to do is define the SelectedItemTemplate in your datagrid. This will automatically hightlight any selected row.
2. DataGrid has a SelectedIndex property which holds an index of the currently selected item. In order to set the variable value all you need to do is define a 'select' button in a grid - framework will automatically take care of assigning the value of the SelectedIndex to the index of the row in which the 'select' button is located when it is clicked.
Cheers
Bug [MCSD]
0
Bug_Bugger
9/20/2004 8:36:36 AM
Thank you very much Bug Bugger,

I can do this now. ^_^
0
kof2005
9/20/2004 9:15:59 AM
Reply:

Similar Artilces:

The row number and offset of each row in the page should have a matching entry in row number table
Is the proper correction for the following to recreate the table BCPout/IN or table to table insert, or just drop and recreate the index? Row number is 0. Is there a way to correct just the data page? Table Corrupt: The row number and offset of each row in the page should have a matching entry in row number table; check this page (page#=772121 row#=0 offset in row number table=0) Table Corrupt: The row number and offset of each row in the page should have a matching entry in row number table; check this page (page#=772121 row#=0 offset in row number table=0) Table Corrupt: The row...

Returning n rows, setting start row, total number of rows
Hi, I'm try to find out how ado.net can perform some of the things i am able to do in ado. Here is the scenario: I will be searching a table that may have 1000's of rows. I want to be able to dictate how many rows (page size) to return and what the starting row number is and be able to find out how many total rows would be returned by the query. Using old ado recordsets I was able to get the recordset and get the count or all the rows (.recordcount - ormaybe it was .rowcount) and then jump to the starting position (.absoluteposition). How can I do the equivalent in .net? From loo...

Get the Row Number or Row ID
Hi, I am using Sybase Central v4.3 with Interactive SQL to query the SQL Commands. My concern is how to get the rownumber or row id in select queries. Is there any in built commands in the ASE. If not please suggest me how to get the rownumber. Thanks.... Unless i'm mistaken, ASE does not use a rowid... it can have a timestamp, but it is updated with every modification to the row. http://infocenter.sybase.com/help/topic/com.sybase.help.ase_15.0.blocks/html/blocks/blocks34.htm -- Cory Sane [TeamSybase] Certified Sybase Associate DBA for ASE 15.0 "Santhanam P" wrote...

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...

I want to select top 3 rows except the first from 4 rows of a Table. It should select from top 2 row,top3 row and top4 row.
 Hi, Let say I've 4 rows in a table. I want to select top 3 rows except the first from 4 rows of a Table. It should select from top 2 row,top3 row and top4 row. Thanks in advance Asghar Ali Mohammed http://www.aliwebdev.com(Web Designer and Developer)Do not forget to "MARK AS ANSWER" on the post that helped you. If you can use Linq, you can use Skip. http://msdn.microsoft.com/en-us/vcsharp/aa336757.aspxThanks, EdMicrosoft MVP - ASP/ASP.NET Hii dear..U can fire the Query select Top(3) from Table1 order by id desc.. "A conclusion is whe...

Get Row Number in Datagrid
Hi I want to delete a databound row in a datagrid using the delete button on the datagrid. I have tried to use Dim RowID As Integer = Convert.ToInt32(shOTQDataGrid1.Items.Item(CInt(e.Item.ItemIndex))) to get the row number. Dim SoqID As Label = CType(shOTQDataGrid1.Items(RowID).FindControl("SOQID"), Label) I need to get the row number(e.g. 0). I search for the specific item "SOQID" and then use a custom Class to delete the record from the Database with the value of SoqID.Text. Dim sh As New ShiftOvertimeQualifiersClass Dim SoqID As Label = CType(shO...

Getting the number of rows in a datagrid
Hi, The datagrid on my webform gets filled with some data from my database. I want to find the number of rows that are populated on the datagrid. What is the way to simply find the number of rows that have been filled with data. I want to use that in a for loop. Thanks, Snigdha After you populate your datagrid with data, all you have to do is:DataGrid.Items.CountThat will give you a count of how many rows are in your grid.DarmarkMark as Answer, if this reply answers your post. Get the row count based on your DataSource....For example, if the DaatSource is DataTable dtTable...it would ...

Selecting a Datagrid row by clicking the row
Hello I am trying to configure my Datagrid so that I can click anywhere on the row and it will invoke the OnItemCommand event and run the associated subroutine. To do this I have created a datagrid with the following: <asp:DataGrid id="dgrdTSOverview_Approved" AutoGenerateColumns="False" OnItemDataBound="Mouseover_Hover" DataKeyField="Timesheet_id" OnItemCommand="dgrdTSOverview_Approved_ItemCommand" ShowHeader="true" BorderWidth="0" CellPadding="2" CssClass="datagri...

Select a Row in DataGrid and Delete this Row
My goal is to put the Rows from one (left) GridView into the secend (right) GridVIew.For this I would like to use Drag and Drop becauce this would do just that but I can find only D&D features in e.g. Dojo. Is it possible in ASP.NET, too?Because I didn't find the D&D solution for ASP.NET I created two GridViews with a SELECT Label for choosing a Row. Then I chosen the SelectedIndexChanged event but when I want to delete the selected row then an error occurs that this isn't possible. Does anyone knows how I can solve my problem? Thank you!  Hello!!Plz see following lin...

How to delete Datagrid row if that row is not selected
Hi, I faced a problem. I have a simple datagrid. It allows user to select a particular row of data say row 5. It works completely fine but if user wants to delete row 7 when row 5 is selected, the datagrid will delete 5 (which is the selected row) instead of 7. How to go about this issue? Thanks! Regards, FrancisSGDOTNET.ORG Can't you just select row 7 and delete it?Thanks!Bernie At first, DataGrid deletes nothing. It sends out only commands that your code has to handle. You have to use DeleteCommand event of datagrid. In this event you have to take the row index from event...

Datagrid Row Row/cell selection
I have a data grid that is displaying the results of a query to a database. It has 4 columns (say appID, FAQID, FAQ, Source). I have created the FAQ column as a TemplateColumn and set it as a LinkButton as I want a new page of the application to load when a user clicks on the FAQ. The new page is to display to complete solution to the FAQ. Is there any way that I can retrieve the value from the FAQID column that relates to the clicked FAQ so that I can pass this to the new usercontrol? Regards, Wallace You could certainly do this. Since you have the FAQID in the one of the ce...

gridview row numbers or row count
In my gridview I want to display the number for each row, so this column doesn't have any relation with any datasource. I want it to display the number of row that it represents, so if I delete a row it still has count and represents the right number of rows that I have in my gridview. Any suggestions are welcome also. I think this thread might have what you're looking for: http://forums.asp.net/p/992655/1292440.aspxMike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/...

How can I count number of rows in each datawindow in composit datawindow then access and set item in each row in each datawindow!
This is a multi-part message in MIME format. ------=_NextPart_000_004F_01C308EA.58A195E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi friends, I created a composite datawindow includes three datawindow. How can I count the number of rows in each datawindow? (Rowcount() function can = not works). Also, I need access in each row then reset the value that I want = in each row in each datawindow. I use the property to access to get data in each row in each datawindow, but the right value only happens in the = fi...

How can I count number of rows in each datawindow in composit datawindow then access and set item in each row in each datawindow!
Hi friends, I created a composite datawindow includes three datawindow. How can I count the number of rows in each datawindow? (Rowcount() function can not works). Also, I need access in each row then reset the value that I want in each row in each datawindow. I use the property to access to get data in each row in each datawindow, but the right value only happens in the first row of each datawindow. It seems I used the loop access the value it doesn't work. Indeed, It has the all data for me but just right for the first row in each data window. Could you have any ideas, please!...

Web resources about - How to set the row number and get the row number for ("selected row) in Datagrid - asp.net.presentation-controls

Resources last updated: 12/16/2015 12:48:02 PM