Walter Graulich

Walter Graulich

  • 1.6k
  • 9
  • 300

Gridview SelectedIndexChange will not populate in correct fields.

May 25 2023 11:43 AM

I have created a webform that has several dropdownlist and textbox as well as a gridview linked to s sqltable.  The Gridview has a column for select to send the data in the row to the selected dropdownlists and textbox so I can edit the data in the sqltable.  When I click on the select button link only a couple of fields are being populated.  I have tried changing the cell #'s in the script and no matter what cell number I select I still can't get some of the fields to populate.

Below are screen shots and the cs code.

These are the fields not populating on select click.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OnCallWeb.Dispatch_Policies
{
    public partial class Workstation_Roles : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

            DropDownList1.Text = dgViewRoles.SelectedRow.Cells[2].Text;
            DropDownList2.Text = dgViewRoles.SelectedRow.Cells[3].Text;
            TextBox1.Text = dgViewRoles.SelectedRow.Cells[4].Text;
            DropDownList3.Text = dgViewRoles.SelectedRow.Cells[5].Text;
            DropDownList4.Text = dgViewRoles.SelectedRow.Cells[6].Text;
        }
    }
}

 


Answers (1)