Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to hightlight a value from the dropdown list using gridview....

how to hightlight a value from the dropdown list using gridview....

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasehelptutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dayakar_dn
    wrote on last edited by
    #1

    Hi All, I need one help regarding gridview, I placed a dropdownlist inside the gridview for a perticular column let us assume that dropdownlist contains items like Pass,Fail and NA. from the Database i will get any value(Pass/Fail/NA), now based on this value i want to highlight the dropdown list with corresponding value. can anybody guid me, how to implement this. i am doing this asp.net with c#.

    N 1 Reply Last reply
    0
    • D dayakar_dn

      Hi All, I need one help regarding gridview, I placed a dropdownlist inside the gridview for a perticular column let us assume that dropdownlist contains items like Pass,Fail and NA. from the Database i will get any value(Pass/Fail/NA), now based on this value i want to highlight the dropdown list with corresponding value. can anybody guid me, how to implement this. i am doing this asp.net with c#.

      N Offline
      N Offline
      nilkatkar
      wrote on last edited by
      #2

      Hi Dayakar, There is an event of gridview called on RowDataBound. In that event you have to bind the dropdown text with the value i.e. coming from database. suppose your dropdownlist name is ddlResult and gridview gvResultSheet gvResultSheet_RowDataBound( object sender, GridVieRowEventArg e) { DropDownList ddlResult; if (e.Row.RowType == DataControlRowType.DataRow) { ddlResult = (DropDownList) e.findcontrol("ddlResult"); if(ddlResult != null && ddlResult.Items.Count > ) { ddlResult.SelectedValue = yourdatasource value; } } } add proper code for yourdatasourcevalue. And let me know if you have some trouble.

      S 1 Reply Last reply
      0
      • N nilkatkar

        Hi Dayakar, There is an event of gridview called on RowDataBound. In that event you have to bind the dropdown text with the value i.e. coming from database. suppose your dropdownlist name is ddlResult and gridview gvResultSheet gvResultSheet_RowDataBound( object sender, GridVieRowEventArg e) { DropDownList ddlResult; if (e.Row.RowType == DataControlRowType.DataRow) { ddlResult = (DropDownList) e.findcontrol("ddlResult"); if(ddlResult != null && ddlResult.Items.Count > ) { ddlResult.SelectedValue = yourdatasource value; } } } add proper code for yourdatasourcevalue. And let me know if you have some trouble.

        S Offline
        S Offline
        Sneha Bisht
        wrote on last edited by
        #3

        gvResultSheet_RowDataBound( object sender, GridVieRowEventArg e) { DropDownList ddlResult; if (e.Row.RowType == DataControlRowType.DataRow) { ddlResult = (DropDownList) e.findcontrol("ddlResult"); if(ddlResult != null && ddlResult.Items.Count > ) { ddlResultItems.FindByText(yourdatasource value).Selected = true; } } } try this.

        N 1 Reply Last reply
        0
        • S Sneha Bisht

          gvResultSheet_RowDataBound( object sender, GridVieRowEventArg e) { DropDownList ddlResult; if (e.Row.RowType == DataControlRowType.DataRow) { ddlResult = (DropDownList) e.findcontrol("ddlResult"); if(ddlResult != null && ddlResult.Items.Count > ) { ddlResultItems.FindByText(yourdatasource value).Selected = true; } } } try this.

          N Offline
          N Offline
          nilkatkar
          wrote on last edited by
          #4

          Thanks Sneha. For adding this in my knowledge base

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups