Getting row number from SelectedIndexChanged??


now, I have 2 template columns, the first is a hyperlink column that consist of userno, the next is the gender which is represented by a radiobuttonlist.
The radiobuttonlist fire up a method when somebody clicks on or change the selected one:

Protected Sub SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim objItem As DataGridItem
Response.Write(CType(DataGrid1.Items.Item(DataGrid1.SelectedIndex).FindControl("hl_oNo"), HyperLink))
End Sub

I need to read the userno from the hyperlink column so that the datagrid knows which userno's gender to update. Hence, I tried to do a response.write so as to try getting the userno from the column. However, it returns an error:
The index is out of range.
I tried replacing selectedIndex to EditItemIndex, but same error appears. I did a response.write of the SelectedIndex, and it is actually -1 for every row.
Next, I tried this:
But, this time, the compiler immediately says that Item couldn't be found inside "e". I think the "e" should be DataGridCommandEventArgs for this line to work. However, I can't change the e of SelectedIndexChanged method, neither can I add another one more argument to the method signature. So, any ideas please?
Any help is greatly appreciated!
10/9/2004 1:38:34 PM 72751 articles. 1 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 50


your Hyperlink fires the DataGrids ItemCommand, thats what you need to evaluate, just like shown in the postings here (descriped with a DDL, but the schema is the same).
10/9/2004 4:35:46 PM
sorry, not the hyperlink fires, the rbl does - the schema is still the same ;)

10/9/2004 5:56:54 PM
okok, but since the hyperlink "fires" the item command, i can't use it.

because my SelectedIndexChanged subroutine has to sort of be able to access the text of the hyperlink column, which is my order number. the hyperlink "fires" the item command only when it is clicked right? In my case, it's not clicked. It is the checkbox which is clicked.
CType(DataGrid1.Items.Item(DataGrid1.SelectedIndex).FindControl("hl_oNo"), HyperLink)

can only seem to access every row of my hyperlink's text values. Any idea please?
Thanx again.
10/11/2004 12:57:17 AM

Similar Artilces:

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

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

Getting Information from the Controls (TemplateField or BoundField ) from any of the Data Presentation Controls
Hello Everybody,I have a very important question for me.For example, I have a GridView.It has three BoundFields and one TemplateFieldI want to get information from any of the record (row,line etc ) using any of the BoundFields or TemplateFields.And also I want to accomplish this not only with GridView but also other Data Presentation Controls, DetailsView FormView and Repeater.Shortly, Can anybody help me how to refer Controls in GridView, FormView, DetailsView, RepeaterPS: I have searched in Google and many sites,forums. But I couldn't see any solution and see that many people ask the same ...

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

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

getting the number of rows...
how can you get the number of rows in query resault with out filling dataset and checking the "count"? afaik - you can't - - you've got to have an entity to count the rows - the dataset is the 'finished product' that contains the result of your query - until you've queried and received the data from the database, you don't know how many rows you've receivedDavid WierMCP/ - where to look first!Control Grouper - easily control properties for multiple controls with one control!Calendar Express - The Best HTML Calendar Generator on the web!(Please 'Mark as ...

How do you get the number of rows
I have a gridview and I want to display the total number of rows of data like 5000 rows? This is not the same as the GridView1.Rows.Count, which gives the number of rows being displayed like 10 of 5000 rows. How do I get at the total? Hi, i think what you are asking is how to get the number of rows of the bounded dataset. Lets say you bound a dataset to the grid, you only need to get the number of rows of the first table in the dataset: myDataset.tables(0).rows.count As simple as that!   regards, njs That works in ASP.NET 1.x That doesn't work in ASP.NET 2.0...

get number from row
if i have a this string to select a row from database of acess: select TOP 1 * from odkazy how i elicit from it id column? i need know id from select row then just get the id... select top 1 id from odkazy... would need an order by clause in the select statement otherwise the TOP has no meaning.. hth***********************Dinakar NethiLife is short. Enjoy it.*********************** my problem: (for example) if i have 5 columns with numbers in select row and i want display cast of this numbers I write: one = ds.tables("Odkazy").Rows(i)("...

How do I get the row number?
I have tryed to find a way to include the row number in a querry but without result. I have a table select some rows ordered and now I will add a column called rank How do I get the rownumber in the field rank ? Thanks in advance Jan O Jan O The way I'd suggest assigning a row number to your resultset is to INSERT your resultset into a temporary table or table variable which has an IDENTITY column, something like this: -- set up a table variable to hold the resultset DECLARE @myTable (Rank int identity(1,1) primary_key, ColumnA va...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

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

Web resources about - Getting row number from SelectedIndexChanged?? -

Does “display:none” render the control ineffective?
I am using a CMS for my site and im trying to alter the Skin of one module in the CMS. I do not have the source code of the module. Only the ...

Resources last updated: 12/30/2015 8:43:34 AM