Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Correctly Reference Row in Sorted GridView
Message
De
14/09/2010 09:07:55
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
How to Correctly Reference Row in Sorted GridView
Divers
Thread ID:
01481100
Message ID:
01481100
Vues:
81
IGNORE!

I worked it out:
Guid premiumRatePK = new Guid(this.grdPremiumRates.DataKeys[e.RowIndex].Value.ToString());
Hi,

I have an ASP.NET form with a GridView on it and am trying to delete a row from it. Here's my code:
        protected void grdPremiumRates_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            DataSet dsPremiumRate = (DataSet)Session["dsPremiumRate"];
            this.oPremiumRate.Delete(dsPremiumRate, e.RowIndex);
            this.BindControl(this.grdPremiumRates);
        }
The grid is defined like this:
<mm:mmGridView ID="grdPremiumRates" runat="server" AccessLevel="Full" AutoGenerateColumns="False"
                            BindingSource="PremiumRate" AllowSorting="True" OnSorting="grdPremiumRates_Sort" DataKeyNames="PremiumRatePK"....
The problem I am having is that the wrong row is getting deleted. I believe this is due to me displaying the grid sorted. So the e.RowIndex references a row in the sorted grid, but the dataset is not sorted when stored in the Session["dsPremiumRate"]. Is there a way that I can get the Primary Key of the row from the grid view and use that rather than the row index?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Répondre
Fil
Voir

Click here to load this message in the networking platform