Specified argument was out of the range of valid values. Parameter

D

Dave

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?');");

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top