473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Passing selected row from gridview to dropdown

Kindly help me passing selected row in gridview to my dropdown. I have 1 gridview, 1 textbox and 1 dropdown list box. My dropdown is populated by SqlDataSource from my table Country. On my gridview, I have 3 columns, which are SELECT, NAME and COUNTRY. Under SELECT column, I have my hyperlinked Select, every time I clicked on a certain row NAME will pass in textbox (no problem with that), but in my dropdown it does not populates the COUNTRY that I choose. For example, I have Jack for name and USA for country. Beside Jack and USA, I have a hyperlink Select, when I click Select, Jack will display on my textbox and supposed to be USA will display on my dropdown but not displaying instead it says an error "'cboCountry' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value".

I have tried the codes below:

Expand|Select|Wrap|Line Numbers
  1. protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
  2. {
  3.    txtname.Text = GridView2.SelectedRow.Cells[1].Text;
  4.    cboCountry.Text = GridView2.SelectedRow.Cells[2].Text;
  5. }
Only the textbox os working, no luck at all in dropdown...I'm using c# and asp.net. Any help would be appreciated. Thanks in advance. God Bless
May 17 '13 #1
1 2525
vijay6
158 100+
Hey PetroTiburcio, first add the country name (i.e., USA) in your 'dropdownlist' then only you can select.
May 17 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: rmccinc | last post by:
I have a dropdownlist in a datagrid and it has autopostback set to true. I need to get the new value of that dropdown to fill a textbox in the same datagrid row. I have set the databind event on...
3
by: Advertis | last post by:
Is there a way to populate a dropdown in a GridView with the next x years? I am using a GridView to display data from a SQL table One of the fields is a Year. I want to have the dropdown list not...
5
by: SA SA | last post by:
Is this possible? I have three items in drop down "Select Payment Type", "Credit Card" and "Check". if user select Credit card then i need to post the form variables to different URL than check...
1
by: Steve Kershaw | last post by:
Hi, I have a GridView in which I have selected a row. I now want to use the 1st column value of that selected row in another GridView as an input to select the particular row in the second...
1
by: gzonit | last post by:
Okay, I've got 3 sections to this form here: http://www.askfritz.com/formQuestion.txt Contact Information, Equipment and Message. I would like to make the Equipment section of the form hidden...
3
by: jmash | last post by:
Hello, The requirement is to display rows of data on a classic ASP page for rows in a recordset. On each row we have a link at the end to show detailed information about the selected row. A...
2
by: anonymoushamster | last post by:
Dropdown A is column from database Dropdown B is column from database Data in A and B must be from same row. If user click an item from A, then B is updated to display its data from...
1
by: hellogohel | last post by:
hi all, how do i display in detailview that is selected from gridview radiobutton? coding dynamically thanks in advance
0
by: furtiveferret | last post by:
Hi I'm still a newbie here, so please bear with me. At the top of the page, I display a gridview as a small scrollbox with 3 sortable columns (customer, region & contact) & a select button for...
1
by: micropos | last post by:
hey,i m newbie to php.i wan ask that how to pass value from drop down menu into database .after click ''go'' button ,it will out.thanks...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.