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

Discussion in 'ASP .Net' started by Dave, Sep 24, 2010.

  1. Dave

    Dave Guest

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

    }
    }
     
    Dave, Sep 24, 2010
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Todd Perkins
    Replies:
    0
    Views:
    9,481
    Todd Perkins
    Sep 15, 2004
  2. subdhar
    Replies:
    9
    Views:
    28,057
    Subhashish Dhar
    Nov 9, 2004
  3. darrel
    Replies:
    0
    Views:
    8,495
    darrel
    Aug 14, 2006
  4. Chapi
    Replies:
    2
    Views:
    10,898
    Chapi
    May 26, 2008
  5. Dave
    Replies:
    11
    Views:
    888
    Jesse Houwing
    Jul 9, 2006
Loading...

Share This Page