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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Getting a selected value from the drop down list inside a GridView on Update

Getting a selected value from the drop down list inside a GridView on Update

Scheduled Pinned Locked Moved ASP.NET
debuggingjsonhelpquestionannouncement
1 Posts 1 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.
  • N Offline
    N Offline
    Norris Chappell
    wrote on last edited by
    #1

    I have a DataGridView, each row has Edit button. After it's clicked, SAPLeader column turns into a drop down list where users can select value. Edit button becomes Update - Getting a null! For some reason the SAPLeader field is not showing my update.The issue is when I display my datagridview gvAccountStaff, I have a column called SAPLeader which has a dropdownlist. When I select a name in the list it errors: Object reference not set to an instance of an object. The SAPLeader field is null. I tried replacing the @SAPLeader with the ddl1.SelectedValue that didn't worked neither. When I debug the event gvAccountStaff_RowDataBound, the datalist shows for the SAPLeader field. However, the dropdownlist is not udpdating when I fire event gvAccountStaff_RowUpdating the value is null by the time it gets there. The rest of the fields are fine. Do I need to bind the gridview again with the datalist? I not sure why it doesn't work. Thanking anyone in advance, Norris aspx code: <%-- --%> <%----%>

    protected void Page_Load(object sender, EventArgs e)
    {
    lblMsg.Text = "";
    if (!Page.IsPostBack)
    {

                gvAccountStaff.DataBind();
                BindSubjectData();
            }
        }
        call to bind gridview
        public class DropDownData
        {
            public DropDownData(int id, string displaytext)
            {
                iD = id;
    
    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