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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:29:19+00:00 2026-05-15T11:29:19+00:00

In a DataGrid, when text in a textbox changes I want to add the

  • 0

In a DataGrid, when text in a textbox changes I want to add the value of another field in that row to an array.

public void txtTitle_TextChanged(object sender, EventArgs e)
{
    TextBox titleBox = (TextBox)sender;
    DataGridItem myItem = (DataGridItem)titleBox.Parent.Parent;
    string test = DataBinder.Eval(myItem.DataItem, "prod_id").ToString();
}

However myItem.DataItem evaluates as null. I was expecting it to evaluate as DataRowView?

  • 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-15T11:29:20+00:00Added an answer on May 15, 2026 at 11:29 am

    Effectively, I solved this by adding an autonumber column to the table, and using the value of this to determine the row’s positino in the table, then using the value of this to affect the appropriate row in the datagrid.
    I’m now merely changing the color of the row rather than adding values in that row to an array, as stated in the original question.

    public void txtPrice_TextChanged(object sender, EventArgs e)
    {
        TextBox txtPrice = (TextBox)sender;
        DataGridItem myItem = (DataGridItem)txtPrice.Parent.Parent;
        markRows(myItem, true);
    }
    
    public void markRows(DataGridItem myItem, bool toSave)
    {
        // Prepeare to save this record?
        CheckBox thisSave = (CheckBox)myItem.FindControl("chkSave");
        thisSave.Checked = toSave;
        // Establish the row's position in the table
        Label sNo = (Label)myItem.FindControl("SNo");
        int rowNum = Convert.ToInt32(sNo.Text) - 1;
        CheckBox rowSave = (CheckBox)grid.Items[rowNum].FindControl("chkSave");
    
        // Update background color on the row to remove/add highlight 
        if (rowSave.Checked == true)
            grid.Items[rowNum].BackColor = System.Drawing.Color.GreenYellow;
        else
        {
            Color bgBlue = Color.FromArgb(212, 231, 247);
            grid.Items[rowNum].BackColor = bgBlue;
            // some code here to refresh data from table?
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET Datagrid with several text boxes and drop down boxes inside
I need to bind the column Header text of a DataGrid to a Resource
I have a datagrid getting bound to a dataset, and I want to display
I have a DataGrid, with an ItemTemplate that has an image and label. In
I have a DataGrid with 5 template columns, However when I try and add
I have a datagrid, populated as shown below. When the user clicks on a
I have a DataGrid where each column has a SortExpression. I would like the
I have a DataGrid, populated with objects in an ArrayCollection. After updating one of
I am using a Datagrid with several columns of data (call it myDG) and
I'm defining a datagrid's RowDetailsTemplate in the following way: RowDetailsTemplate={StaticResource defaultTemplate} where <UserControl.Resources> <DataTemplate

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.