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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:05:20+00:00 2026-05-29T10:05:20+00:00

How to change the value of a text block inside a grid view in

  • 0

How to change the value of a text block inside a grid view in WPF based on the check box selection . Grid view in WPF is populated from a sql table which has ID and Value as columns.Value here is YES or NO.I am using linq to sql .
I have a check box associated to each ID in the grid view.when a user selects some rows ,i have to save the changes back to the database.

So based on the selection i have to change the value field in the row in this fashion:

If the text in the “Value” field of the grid view is “YES” then i have to change it to “NO”
If the text in the “Value” field of the grid view is “NO” then i have to change it to “YES”

I am able to populate data into the gridview ,but i am not sure whether my questions in the above scenario will fit in WPF and c#.Need some guidance.

  • 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-29T10:05:20+00:00Added an answer on May 29, 2026 at 10:05 am

    The best way to do this is to bind both the Text block and the checkbox to the same backend field in the data model and then to use code converters.

    Here is a simple example.

    Say you have the following simple view model with one bool property:

    class SimpleViewModel: INotifyPropertyChanged
    {
        private bool _checked;
        // The property to bind to
        public bool Checked
        {
            get { return _checked; }
            set { _checked = value; OnPropertyChanged("Checked");  }
        }
    
        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));  
        }
    }
    

    Here is also a simple page with a text block and a text field that both bind to the same backend field.

    <Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WpfApplication1"
        Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
           <local:SimpleViewModel x:Key="simpleViewModel" />
           <local:BoolToStringConverter x:Key="boolToStringConverter" />
        </Window.Resources>
        <Grid DataContext="{StaticResource simpleViewModel}">
           <StackPanel>
              <TextBlock Text="{Binding Checked, Converter={StaticResource boolToStringConverter}}" />
              <CheckBox Content="something" IsChecked="{Binding Checked}" /> 
           </StackPanel>
        </Grid> 
    </Window>
    

    Now notice that the text block binding statement contains a converter statement.
    Text="{Binding Checked, Converter={StaticResource boolToStringConverter}}"

    The converter here is very simple. It checks the value if it’s true and returns Yes, otherwise returns NO.

    public class BoolToStringConverter:IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null) return null; 
    
            if ((bool)value == true)
                return "YES";
            else
                return "NO";
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            // this scenario is not needed since the text block is read only
            throw new NotImplementedException();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't change the value of the text field (with the id code) to
I need to change some text values inside an after effect project file that
Is there any way to change the value of property at runtime in WPF
Goal I have a WPF application that contain text inside a DataGrid . I
How can I write single UPDATE query to change value of COL1 to ‘X’
basically need to change the value that - admin_url() returns any idea?
Every time that I change a value in the designer after saving it, the
How to hook to the property value change notification for properties of a FrameworkElement?
Is there a way to change the value contained in an NSNumber after it
I am trying to programmatically change a value of a wxRadioButton in a way

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.