Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8630237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:01:09+00:00 2026-06-12T09:01:09+00:00

When i am click on update button i got this error my update click

  • 0

When i am click on update button i got this error
my update click event

protected void btnUpdate_Click(object sender, CommandEventArgs e)
{
    int idx = Convert.ToInt32(e.CommandArgument);
    GridViewRow gr = gvResTasks.Rows[idx];
    ...
}

when idx value is upto 19 it works fine ..when it is greater than 19 this error came..
could you please help me on this

Updatebutton.aspx

<ItemTemplate> <asp:Button runat="server" ID="btnUpdate" Text="Update" OnCommand="btnUpdate_Click" CommandArgument="<%# Container.DataItemIndex %>" /> <%--<asp:Button runat="server" ID="Button1" Text="Update" onclick="btnUpdate_Click" />--%> </ItemTemplate>    

updatebutton.aspx.cs

protected void btnUpdate_Click(object sender, CommandEventArgs e)
{
   // int idx = Convert.ToInt32(e.CommandArgument);
    int idx = Convert.ToInt32(e.CommandArgument);
    GridViewRow gr = gvResTasks.Rows[idx];

    Label hf = (Label)gr.FindControl("hdEmployeeID");

    string sEmpID = hf.Text;
    lblEmployeeID.Text = sEmpID;
    lblEmployeeID2.Text = sEmpID;

    int Rows = gvResTasks.Rows.Count;
    for (int x = 0; x < Rows; x++)
    {
        GridViewRow tr = gvResTasks.Rows[x];
        tr.CssClass = "WhiteBack";
    }

    ClearMessages();

    gr.CssClass = "TealBack";

    string sSubTaskID = gr.Cells[0].Text;
    lblSubTaskID.Text = sSubTaskID;

    lblSubTaskName.Text = @gr.Cells[1].Text;

    LoadSubTaskInfo();

    Single sProgress = 0;
    Boolean bok = Single.TryParse(lblActualProgress.Text, out sProgress);




    DateTime dPF = DateTime.Parse(lblPlannedFinish.Text);

    if (dPF > DateTime.Now)
    {
        btnFinish.Enabled = false;
    }
    else if (dPF <= DateTime.Now)
    {
        if (sProgress >= 100)
        {
            btnFinish.Enabled = false;
        }
        else
        {
            btnFinish.Enabled = true;
        }
        //btnFinish.Enabled = true;
    }

    panelUpdate.CssClass = "float";
    panelUpdate.Visible = false;
    if (gr.Cells[7].Text != "True")
    {
        panelUpdate.Visible = true;
    }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:01:09+00:00Added an answer on June 12, 2026 at 9:01 am

    No need to use e.CommandArgument to find the GridViewRow. Just do this

    GridViewRow gr = ((Button)sender).NamingContainer as GridViewRow;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got this event in my page aspx.cs: public void deleteBtn_Click(object sender, CommandEventArgs
I can't figure out why this simple update command won't work: private void button1_Click(object
Here is my function: private void btnSave_Click(object sender, EventArgs e) { wO_FlangeMillBundlesTableAdapter.Update(invClerkDataDataSet.WO_FlangeMillBundles); wO_HeadMillBundlesTableAdapter.Update(invClerkDataDataSet.WO_HeadMillBundles); wO_WebMillBundlesTableAdapter.Update(invClerkDataDataSet.WO_WebMillBundles);
I got this error upon testing on how to update the particular column in
Basically I've got an update query that runs when you click a submit button.
How to Update a div tag in Master Page using a button click in
I have a button which is in update panel. When I click on button
No this isn't a copy of this question: Button in update panel is doing
UPDATE: I narrowed it down, when I got rid of this tag in the
I've got a FlowDocument which has some elements like so: <InlineUIContainer> <Button Click=Button_Click Tag=123456789890>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.