0

I have a gridview with no datakeys. When I click the row edit button, I'm taken to the rowediting method. I've tried several ways to get the row index, but no luck.

   protected void gvwCustomerLocation_RowEditing(object sender, GridViewEditEventArgs e)
   {
        var index1 = e.NewEditIndex;  //gives me an incorrect index number

        //The SelectedIndex always equals -1
        for (int i = 0; i < gvwCustomerLocation.Rows.Count; i++)
        {
            if (gvwCustomerLocation.SelectedIndex == 1)
            {

            }
        }

        int index = gvwCustomerLocation.EditIndex;  //The EditIndex = -1

        GridViewRow row = gvwCustomerLocation.SelectedRow;  //The SelectedRow = null
        var test = row.RowIndex.ToString();
   }

How can I get the selected row index?

1 Answers1

0

I eventually gave up on getting a row index from my gridview and decided to make a primary key in my sql server result set to use as my key in the front end.