Passing selected row from gridview to dropdown

Discussion in 'C Programming' started by PetroTiburcio, May 17, 2013.

  1. PetroTiburcio

    PetroTiburcio

    Joined:
    May 17, 2013
    Messages:
    7
    Likes Received:
    0
    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:

    Code (Text):
    protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
    {
    txtname.Text = GridView2.SelectedRow.Cells[1].Text;
    cboCountry.Text = GridView2.SelectedRow.Cells[2].Text;
    }
    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
     
    PetroTiburcio, May 17, 2013
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. =?Utf-8?B?U3VyZXNo?=
    Replies:
    1
    Views:
    710
    Saravana
    Nov 22, 2004
  2. Charles Shao
    Replies:
    1
    Views:
    566
    Eliyahu Goldin
    Apr 18, 2005
  3. vishnu
    Replies:
    1
    Views:
    1,557
    Patrick.O.Ige
    Mar 25, 2006
  4. H5N1
    Replies:
    0
    Views:
    3,124
  5. maurban@gmail.com
    Replies:
    5
    Views:
    979
    maurban@gmail.com
    Oct 13, 2006
  6. Ken Fine
    Replies:
    4
    Views:
    671
    Steven Cheng [MSFT]
    Jul 14, 2008
  7. ujjc001@gmail.com

    Want to add row under selected row of gridview

    ujjc001@gmail.com, Feb 16, 2007, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    689
    ujjc001@gmail.com
    Feb 16, 2007
  8. needin4mation@gmail.com

    Selected Row Only GridView Row Visible?

    needin4mation@gmail.com, Oct 17, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    538
    needin4mation@gmail.com
    Oct 17, 2006
Loading...