Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Correctly Reference Row in Sorted GridView
Message
From
14/09/2010 09:07:55
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
How to Correctly Reference Row in Sorted GridView
Miscellaneous
Thread ID:
01481100
Message ID:
01481100
Views:
80
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
Reply
Map
View

Click here to load this message in the networking platform