From: Dave on 24 Sep 2010 12:18 I have a GridView that I'm trying to implement a Confirm OnDelete. The below code works except that I'm getting the error "Specified argument was out of the range of valid values. Parameter name: index" when ever I click Update. I know that this is happening because there are no controls now in that cell. What condition can I test against? Thanks /////////////////CODE///////////////////// <asp:GridView ID="SOCCatGridView" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ssoccID" DataSourceID="CATGridSqlDataSource" OnRowDataBound="SOCCatGridView_RowDataBound" OnRowDeleted="SOCCatGridView_RowDeleted" OnSelectedIndexChanged="SOCCatGridView_SelectedIndexChanged" BackColor="White" AutoGenerateDeleteButton="True"> <Columns> <asp:CommandField ShowSelectButton="True" /> <asp:BoundField DataField="ssoccID" HeaderText="ssoccID" InsertVisible="False" ReadOnly="True" SortExpression="ssoccID" Visible="False" /> <asp:BoundField DataField="DisplayOrder" HeaderText="Order" SortExpression="DisplayOrder" /> <asp:BoundField DataField="SOCCategory" HeaderText="SOC Category" SortExpression="SOCCategory" /> </Columns> <EmptyDataTemplate> There are no Categories defined. </EmptyDataTemplate> </asp:GridView> /////////////// C# Code ////////////// protected void DetailGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton db = (LinkButton)e.Row.Cells[0].Controls[1]; db.OnClientClick = string.Format("return confirm('Are you certain you want to delete this record?');"); } }
|
Pages: 1 Prev: How to prevent outsiders from accessing ASP.Net intranet website? Next: Login Redirection |