Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Getting Error in Rowcommand Event :Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

$
0
0

hi..getting error here int addid = Convert.ToInt32(gvImages.DataKeys[rowindex]["CategoryID"]); that "Error:Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

i was declared the commandArgument='<%# Container.DisplayIndex %>' like this..

Plz help me..urjent..

protected void gvImages_RowCommand(object sender, GridViewCommandEventArgs e)
    {

        int rowindex = Convert.ToInt32(e.CommandArgument);//Identifying the row

        try
        {
            int addid = Convert.ToInt32(gvImages.DataKeys[rowindex]["CategoryID"]);
            ViewState["AddId"] = addid;
        }
        catch (ArgumentOutOfRangeException ex)
        {
            throw new ArgumentOutOfRangeException(
                String.Format(
                    "The index passed is not valid for the collection.  The index is '{0}' and must be between 0 and '{1}'.",
                    rowindex,
                    gvImages.DataKeys.Count));
        }
      
       
        if (e.CommandName == "Edit")
        {
           
            btnupdate.Visible = true;
            btnsubmit.Visible = false;
            
            //txtName.Text = gvImages.DataKeys[rowindex]["Name"].ToString();
            //txtSynonyms.Text = gvImages.DataKeys[rowindex]["Synonyms"].ToString();
            //txtTelugu.Text = gvImages.DataKeys[rowindex]["TeluguName"].ToString();
            //txtUsage.Text = gvImages.DataKeys[rowindex]["Usage1"].ToString();
            //txtVerbForms.Text = gvImages.DataKeys[rowindex]["VerbForms"].ToString();
            //txtDescription.Text = gvImages.DataKeys[rowindex]["Description"].ToString();
            //imgdisply.ImageUrl = "~/Image/" + gvImages.DataKeys[rowindex]["Image"].ToString();


        
        }





    }


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>