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 6357779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:14:10+00:00 2026-05-24T23:14:10+00:00

I am trying to use the update method for the gridview and its simply

  • 0

I am trying to use the update method for the gridview and its simply returning null

    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        TextBox Currency = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Currency"));
        GridView1.EditIndex = -1;

        if (!Page.IsPostBack)
        {
            FillTravelers();
        }
    }

Any ideas? when I press update it just returns the field to its previous value but returns nothing.

Thanks

  • 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-05-24T23:14:10+00:00Added an answer on May 24, 2026 at 11:14 pm

    As your Gridview is in its simplest form with no controls defined in the gridview (and hence there is no Currency textbox defined in the GridView), please check the datasource of GridView1 which I assume would be a Datatable.
    Then you need to identify which column of the Datatable is the Currency column.

    For e.g., for the below datatable, it would be column 2.

      DataTable taskTable = new DataTable("AmountList");
      taskTable.Columns.Add("Id", typeof(int));
      taskTable.Columns.Add("Currency", typeof(string));
      taskTable.Columns.Add("Amount", typeof(decimal)); 
    

    Based on this, you can retrieve your updated Currency value using the following code below.

        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = TaskGridView.Rows[e.RowIndex];
            GridView1.EditIndex = -1;
            TextBox txtCurrency = (TextBox)(row.Cells[2].Controls[0]);
            if (!Page.IsPostBack)
            {
                FillTravelers();
            }
            //... Rest of the code
        }
    

    Please note that if the Currency column is different above, then you need to change the index of rows.Cells[index].Controls[0] too. For e.g., if Currency is at column 5, then the txtCurrency definition becomes:

     TextBox txtCurrency = (TextBox)(row.Cells[5].Controls[0]);
    

    If you are not able to figure out the column index of the datatable easily (or if you are using a more complicated datasource), then, assuming the GridView1 does not have too many columns, I would recommend trying to increment the Cells index step by step until you see the updated value in the Watch for row.Cells[index].Controls[0] while debugging.

    Edit: (Adding code to retrieve the column index of the Currency column)
    You can pass “Currency” as a string and the OracleDataReader instance to the below method and this should give you the column index (or it gives you -1 if there is no Currency column in the OracleDataReader).

    private int GetColumnIndexIfExists(OracleDataReader dr, string columnName)
    {
        for (int i = 0; i < dr.FieldCount; i++)
        {
            if (dr.GetName(i).Equals(columnName))
            {
                return i;
            }
        }
        return -1;
    }
    

    Then in the actual code, you can modify add 1 to the cell index as shown below because the cell index is not zero based like the column index.

    TextBox txtCurrency = (TextBox)(row.Cells[i+1].Controls[0]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update: I put the complete code for reference I'm trying to use Dispatcher method
I'm trying to use a custom object's method to emit to a socket connection.
I am trying to use an update query to update the first 3 characters
I am trying to use an update trigger in SQL Server 2000 so that
I am trying to use an xmlpoke task to update a VS Project File
I'm trying to use System.IO.File.Replace to update a file, and it's throwing System.IOException if
I am trying to use jQuery's ajax functionality to update data from a web
I am trying to use this MySQL query: SET @a:=0; UPDATE tbl SET sortId=@a:=@a+1
I use an old Powerbook G4. While trying to update the macports (sudo port
I'm trying to use the method recreate_versions! but I'm using the method from the

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.