Select option selection

I'm created a gridview of websites, in one column, and use the gridview's 'selection' featue in the next column. When I click the 'selection' link I tried to get the website by using:

Dim key As String = grvPrivacy.Rows(e.RowIndex).Cells(1).Text

but it said it was not part of the webcontrol for selection. How do I get cell so that I can read it?



8/24/2007 7:16:28 PM 72751 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 27

Looks like your grabbing the select option and not the first cell


Dim key As String = grvPrivacy.Rows(e.RowIndex).Cells(0).Text

werD, MCSD VB.Net

8/24/2007 11:26:52 PM

Hi, gmcghee:

There are several ways to get the values from a GridViewRow.

1. Use FindControl method. Assume there is a control whose ID is "TextBox1", you can get the textbox by TextBox tb = (TextBox)row.Find("TextBox1"). 

2. Use DataKeyNames. If one field is readonly or invisible, you can add it to DataKeyNames of GridView and get its value like

3. Use control index. Assume the third control in the first cell is a TextBox, you can get get it like TextBox tb = (TextBox)row.Cells[0].Controls[2];

4. Get the text of the cell
   If you assign a value to the Cell's Text propery, the controls in the cell will be cleared. Only the Text if displayed. You can get the Text by
   Be sure the correctness of the Index.

Hope it helps.
If you have any doubts about it, please feel free to post back.

Techie Zhang
Microsoft Online Community Support
8/27/2007 5:55:43 AM

I still get the same error, " RowIndex is not a member of 'System.Web.UI.webControls.Gridview.SelectEventArgs' Here is the code so far:

Imports System.Data
Imports System.Data.OleDb
Imports System.Data.OleDb.OleDbDataReader

Partial Class privacyscans_privacyupdate Inherits System.Web.UI.Page

  Protected Sub grvPrivacy_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs)  Handles grvPrivacy.SelectedIndexChanging

    Dim key As String = grvPrivacy.Rows(e.RowIndex).Cells(0).Text

  End Sub

End Class

This is the Gridview Code from the page:

<asp:GridView ID="grvPrivacy" runat="server" Width="100%" CellPadding="5" CellSpacing="0" Caption="Select a Privacy URL" CaptionAlign="top" AutoGenerateColumns="False" DataSourceID="AccessDataSource1">

<asp:BoundField DataField="url" HeaderText="URL" HeaderStyle-HorizontalAlign="center" SortExpression="url" />
<asp:CommandField ShowSelectButton="True" HeaderText="Select" />



<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/database/accmon.mdb"
SelectCommand="SELECT [url], [privacyscanDelete] FROM [privacyscan] WHERE ([privacyscanDelete] = False)"></asp:AccessDataSource>



8/27/2007 2:16:12 PM

Hi, gmcghee :

Sorry for the late replay.

The class GridViewSelectEventArgs hasn't a member RowIndex, you should use the e.NewSelectedIndex stead of e.RowIndex.

Please have a try.

Techie Zhang
Microsoft Online Community Support
9/3/2007 1:52:02 AM

Similar Artilces:

Hi! I remember seeing an example where you can do a select from a nested select, but I cannot seem to make it work. So it would be something like this: select max( name ) from ( select name from customer union select name from vendor ) Was I dreaming I saw that? Thanks! D In article <4500243f@forums-2-dub>, says... > Hi! > > I remember seeing an example where you can do a select from a nested > select, but I cannot seem to make it work. No, you weren't. Try (UNTESTED!) adding a...

Select control option selected attribute modified so page is broken
When you have an html select control on the page with an option marked as selected using syntax like this: <select id="drpCust" runat="server"> <option selected>(please select)</option> <option value="1001">Jones, Mary</option> <option value="1002">Stevens, Jim</option> <option value="1003">Robins, Sylvia</option> <option value="1004">Chong, William</option> </select>...

Forms , Select and option selected.
Name: Jirrick Email: jurahudecatgmaildotcom Product: Firefox Release Candidate Summary: Forms , Select and option selected. Comments: I've found problem with SELECTED option in <select> forms. I wanted to use pre-selected option in my form , but when I used the Firefox 3 RC1 to render it there wasn't any preselected item. I tried to rewrite code ( use selected="selected" ) , but still no effect. I was confused and tried to use others viewers ( IE 8 , OP 9 , Konqueror ) and the pre-selected item worked well in these browsers. The bug has to be in FF 3 ...

Why is the select saying selected after an item is selected?
This was a whitelisting issue due to a software upgrade at hostgator..  Nothing wrong with my code..Scot King SEO Software Tool | Search Engine Optimization"Get your page rank high"  huh? It is smart to put your question in the body and not just in the title. Have no idea what your question is or if it even a question.Eric | Twitter epascarello | LinkedIn use thisddl.options[ddl.selectedIndex].selected = false; //Clear the selection ddl.options[1].selected = trueMAKMark as Answer if this reply helps youMVP ASP/ASP.NetASP.Net Hosting : Host DepotMy Sit...

My DropDownList doesn't let me select the first option. Also goes back to first option after another option is selected.
 I have a DDL on a page. It's populated by a SqlDataSource, and when a value is selected, I take the orgID from that value to populate a list box. The list box is populated with every store that is tied to that orgID. I can get the list box to populate with the right values for every value in the ddl except for the first one. It's like I can't click on the first value, and whenever I select another value, the list box populates, then the ddl reverts back to the first value no matter which other value I selected.  Here's my ddl: <asp:DropDownList ID="Dro...

Problem in Using DropDownList Control to select a selected row of SqlDataSource that is under GridView Control
Hi all,In my SQL Server Management Studio Express, I have a database "ChemDatabase" that has a table "LabData"  formatted in the following way: SampleID int PRIMARY KEY, SampleName nvarchar(25), ChemicalName, nvarchar(25), Concentration decimal(6.2) with 5 rows of records in this .dbo table. In my Visual Web Developer Express, I created a website "RPD-TCE" for extracting a row of record from the LabData table by using a DropDownList, a GridView and a SqlDataSource.  I want to click DropDownList to list one number of S...

Option Selection is lost in Grid when I postback , but I can get the option value (just selection point only lost)
hi All,I'm using option buttone (html control) in a Grid Which is working properly...If I postback the form by any other control my previous Selection is lost...I need to apper the selection after the form postback.PRabakar I guess you are using plain html controls, right?. Consider converting those to server side html controls by adding runat="server" to the declaration of the radio buttons. You will have to make sure viewstate of the grid is enabled CheersBug [MCSD]...

how to add a default select to select html control
 how to add a default text to a htmlselect control i am getting values from database and binding to select control and i want to hv a item as my first item as  in the html control  as "select  " i want to have select item as my first item in select html controlhow can i do it   srinu. Are you open to doing this in the code behind?  If so, use a DropDownList control, and handle the DataBound event where you can insert the default item at position 0.C# <---> VB.Net Translator...

Selecting the items in a CheckBoxList control that are already selected
Simple problem here.  I’ve not used a CheckBoxList control in an ASP.NET application before (ASP.NET 3.5 in this case), and now I need to.  Databinding it to the source to populate the items of the list is easy.  However, selecting those items which are already stored in the database; I’m not sure how I can do that with databinding. So the question is, how do I databind the items in the CheckBoxList which reflect the items already selected in the database, in this case in a resolution table between the data items table and the lookup table, so that I get what’s in the res...

Selecting already selected date in Calendar control
Greetings,  I have a calendar control inside an UpdatePanel. As indicated in the documentation (and verified by testing), the SelectionChanged event is triggered only if the selected date is changed. That is, it does not trigger if the user clicks on the already selected date.  However, clicking on the already selected date does cause an async postback of the UpdatePanel that contains the calendar.  So, my question -- how can I determine that the cause of the postback was the user clicking a second time on the calendar control? There does not appear to be a ...

select in the select statement
Hi, I am trying to add another select statement in my original/outer/overall select statement. Something like: Select 1, 2, 3 = (Select # from Table1 Where....) From Table 2 Where.... Does anyone know the standard way to write this or is there any other alternative that can perform the same behavior. Much thanks!! Kenny That's database dependent. In oracle you would use: select A.* from ( select * from mytable) A -- Terry Dykstra (TeamSybase) Please state PB / OS / DB versions in your post. MySybase "Kenny Tran" <...

insert select and select into
Hello, I am using temp tables to generate a report. I created most of the temp tables and then use insert select. I found for one, when I use insert select, I get a different query plan than if I use select into. The select into get a much better performance. The problem is I get dead locks on the statement. Is there anything I can do to change this behavior? Thanks, Josh Manfred ...

How to get Select text for atlas client control Select
There ASP dropdownlist. After user select one item in this list, I want to get the selected text, not seleted value. For example, from the following code, when user select 1998, I want to get the text "1998", not the value "1".If I use function get_selectedValue(), I will get the selceted value "1", not the text "1998".How do that in Atlas client script? Year:<select name="ctl00$ContentPlaceHolder$ctl01$DropYYYY" id="ctl00_ContentPlaceHolder_ctl01_DropYYYY" style="width:64px;">    <option value="-1">Select...</option>    <option value="...

Select in the select clause
How to use another select clause within a select clause itself. Like; select col1,col2,(select colx from table b) from table a . The above statement is throwing syntax error Thanks, Anandkumar B CGVAK Software & Exports Ltd. ( 0422 2434491/92 "anand_group" <> wrote: > How to use another select clause within a select clause itself. > Like; > select col1,col2,(select colx from table b) from table a . > The above statement is throwing syntax error Ensure that subquery returns only one row. And...

Web resources about - Select option selection -

Selection - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Megan Jones is seeking a faster cross country time to boost hopes of Olympic selection - AdelaideNow ...
SOUTH Australian Megan Jones had a simple wish on the eve of the talent-laden four-star competition at the Adelaide International Three Day Event. ...

Victoria tells coach David Saker to quit criticising Australian cricket team selections
The maverick Victorian coach David Saker will be told to button his lip on matters concerning the Australian team and its selection, after angering ...

The Law Firm Selection Guide
Download our Law Firm Selection Guide.

Jury Selection Begins for Officer Charged in Gray's Death
CBS Local Jury Selection Begins for Officer Charged in Gray's Death CBS Local BALTIMORE (WNEW/AP) — Jury selection for the first police officer ...

Jury selection to begin in first Freddie Gray trial
Officer William Porter could spend at least 10 years in prison if convicted for his alleged role in the death of the 25-year-old black man

Cubs' Kris Bryant unanimous selection as NL Rookie of the Year
Chicago Tribune Cubs' Kris Bryant unanimous selection as NL Rookie of the Year Chicago Tribune Bryant, 23, set franchise rookie records with ...

Jury selection begins in the first of six trials in Freddie Gray case
... in the back of a police van, the trial for the first of six Baltimore police officers accused of killing him is officially underway. Jury selection ...

The Latest on Freddie Gray: Jury Selection in Officer Trial
The Latest: Jury selection in its 2nd day for officer's trial over death of Freddie Gray

Here Are Jezebel's Selections For People's Sexiest Man of the Year
It takes 56,000 People staffers just over 330 days to meet and interview all the men in the world, but by god, they do it every single year and ...

Resources last updated: 12/6/2015 3:06:55 PM