.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Cell value changed event(?) in DataGrid

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :JQuery

What would be a good way to capture a change in a cell value and act on it (e.g. flash the background)?

The only thing that I could come up with was using Binding.TargetUpdated.  It works fine with the exception that when you scroll a virtualized grid TargetUpdated is obviously also fired. There has to be a better way to do something simple like this ...

View Complete Post

More Related Resource Links

How do I make a DataGrid fire an event when a cell is changed?


I tried to figure this out a while ago but gave up - now I'm in a situation where I need to try again.

I have a DataGrid (using .NET 4) and I'm trying to fire an event when a cell is changed.  However, I cannot generate any events until a different row is selected.  So, for example, I have a datagrid with a checkbox column and I want an event to occur when the user changes one of the checkboxes.  As it is right now, I can't generate an event until the user selects another row after changing the checkbox.

I've tried every type of event I can find - RowEditEnding, CellEditEnding, CurrentCellChanged, MouseLeftButtonUp, MouseLeftButtonDown, etc.  None is ever fired when the checkbox is changed - they don't fire until another row is selected.

So, I can click away on a checkbox hundreds of times and no events will be generated.  As soon as I change rows, though, the events occur.

Any help with this one?  This is such an elementary problem I'm sure there's something basic I'm missing.  Suffice it to say, I don't use WPF very often :)  I've seen the same question asked elsewhere and there are supposed answers but they are extremely complicated and I can't get them to work.

Thanks in advance,


KeyUp event on DataGrid cell or column




I've a DataGrid in my wpf, and I'm creating my columns dynamically via code,

i want to handle the key event on the dataGrid column.

how can i handle event on dataGrid column (something like dataGridView has in winforms).

here is an example:

col = new DataGridTextColumn();
            col.Header = "sum";
            col.Width = new DataGridLength(15, DataGridLengthUnitType.Star);
            col.Binding = new Binding("sum");




Setting focus on cell in datagrid after CollectionChanged event.




Having trouble setting the focus on a cell after the collection recieves a new row. This is my code:

 sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
			DataGridRowObjects<My_DataGridRow> oc = (DataGridRowObjects<My_DataGridRow>)sender;
 (e.Action == NotifyCollectionChangedAction.Add)
				//set focus to column 2 of the new row

				DataGridCell cell = my_datagrid.GetCell(e.NewStartingIndex, 2);
 (cell != null
				 DataGridCellInfo info = new
				 my_datagrid.CurrentCell = info;

Is there any event that fires after the CollectionChanged? My DataGridRow doesn't have a CellPresenter att this stage and GetCell fails. If I do the same with a button event instead, it works fine.

I just tried to add a dispatcher message instead but that did nothing:

Dispatcher.BeginInvoke(new Action(delegate()
  //set focus to column 2 of the new row
  DataGridCell c

How to get the combobox value inside Datagrid on Edit button click event

Hi     I have Datagrid template column like<DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn>DataGridTemplateColumn Header="Edit" x:Name="Edit" ><DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn.CellEditingTemplate></DataGridTemplateColumn>SelectionChanged="cmbDGTeam_SelectionChanged" IsTabStop="True" /></DataTemplate><ComboBox Height="22" IsEditable="True" IsReadOnly="True" ItemsSource="{Binding}" DisplayMemberPath="Title" SelectedValuePath="TeamID" x:Name="cmbDGTeam"  SelectedValue="{Binding Path=TeamID,Mode=TwoWay}"<DataGridTemplateColumn.CellEditingTemplate><DataTemplate><DataTemplate><TextBlock Text="{Binding Title}"/></DataTemplate></DataGridTemplateColumn.CellTemplate><DataGridTemplateColumn Header="Team" Width="75"><DataGridTemplateColumn.CellTemplate> and Edit button Template column <DataGridTemplateColumn Header="Edit" x:Name="Edit" > </DataGridTemplateColumn.CellTemplate></DataTemplate><Button Content="Edit" IsEnabled="False" x:Name="btnEdit" Click="btnEdit_Click" ></Button>&l

Infopath Changed Event code triggering in preview but not in web filler.

Hi there, I've written some code for a changed event hookup on a field in infopath 2010. The form is for submission to a sharepoint 2010 forms library. What the code does is fill in a specific value into a field depending on the selected value from a combo-box elsewhere on the form. When i preview this in Infopath 2010 it works perfectly but when i fill out the form through the web interface it simply does nothing. I've got another piece of code which executes on load and this works perfectly in both the preview and the web filler. What it does is just set the value of a field when the form loads. Here is the code, could someone tell me what i'm doing wrong? public void InternalStartup() { EventManager.XmlEvents["/my:myFields/my:service_level"].Changed += new XmlChangedEventHandler(service_level_Changed); EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading); } public void service_level_Changed(object sender, XmlEventArgs e) { // Write your code here to change the main data source. XPathNavigator xroot = MainDataSource.CreateNavigator(); XPathNavigator serviceLevel = xroot.SelectSingleNode("/my:myFields/my:service_level",NamespaceManager); XPathNavigator xest = xroot.SelectSingleNode("/my:myFields/my:est_cost", NamespaceManager); switch (serviceLevel.Value)

Handle MaxLength changed event for TextBox

Hi, Is it it possible to handle the event when MaxLength property is changed on a TextBox? Thanks, cp

DataGrid Button + event in Footer, event not getting fire!

hi.First Time i am trying this...I have one Datagrid with Footer. Footer Row Contains Input fields with one Button to add New Values. I have button click event but not getting fires. my code follows:protected void dgPrice_ItemCreated(object sender, DataGridItemEventArgs e)    {            Button btnAdd = new Button();            btnAdd.Text = "Add";            btnAdd.Width = 80;            btnAdd.ID = "btnAdd";           // btnAdd.Attributes.Add("onClick", "return validateRates()");            btnAdd.CommandName = "add";            btnAdd.CommandArgument = e.Item.ItemIndex.ToString();            btnAdd.Command +=new CommandEventHandler (PriceNew);            e.Item.Cells[6].Controls.Add(btnAdd);}protected void PriceNew(object sender, EventArgs e)    {}btnAdd.command/ btnAdd.click event not getting fired I also tried to

Raise OnPropertyChanged event when Text Box Text has changed

Hi there I have a Wrapped Text Box that is bound to a Public String Property. I have a related OK Button that should be Enabled when the text changes to indicate there are 'items' in the Text Box. The problem is that the set accessor of the property (and thus OnPropertyChanged) is not being called until focus is lost from the text box - and I would like the Ok Button to be enabled before then. What is the the best way to raise the set when the Text Box text has changed? (A List Box is not an option) Thanks very much Joe

Checkbox checked changed event inside gridview

Hi All, In my gridview there are 8 checkboxex in each row : 'Sunday' to 'Saturday' and one for 'All'. If 'All' is checked in a particular row, all other checkboxes in that row should be checked instantly, and viserversa. Can i do this in checkbox checked_changed event, if so how do i access the current row of the gridview in the checked changed event? Thanks in advance

Get Cell Value of DataGridComboBox Column for WPF DataGrid

hello Friends I am using WPF Datagrid (WPFToolKit Control) in my appliction I Have a DataGridComboBox Column which is filled with some records.  <WpfToolkit:DataGridComboBoxColumn ScrollViewer.CanContentScroll="True" CellStyle="{StaticResource LeftAlignedCellStyle}" Header="Item Code" x:Name="CmbItems" Width="250" SelectedValueBinding="{Binding ITEMCODE}" DisplayMemberPath="ITEMDESC" SelectedValuePath="ITEMCODE"  > </WpfToolkit:DataGridComboBoxColumn> Now how to get selectedText of that combobox for current row. my current focus on other cell  Please Help Me regards Vipul

How to stop Datagrid SelectionChange from SelectionChanged Event



I have a DataGrid which is binded with a List. Consider I have 10 Items in the List, so in the combobox also.

Currently 2nd Item is selected in the DataGrid.

Now I am selecting the 3rd item in the DataGrid.

In the DataGrid SelectionChanged event, I am doing some validation and validation fails so I don want my Selection is changed from 2nd item to 3rd item or the selection should remain in 2nd item.

Please let me know how to do this?

In the DataGrid SelectionChanged event, I tried to set DataGrid.SelectedItem = 2ndItem.

But this didn't work properly.

Hope, my requirement is clear. If you have any doubt then please feel free to ask me.



gridview and textbox changed event



i have a textbox changed event i am calling this event  when textbox  value changed.

this textbox is inside gridviews Itemtemplate

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowUpdating="Update_Schedule"
                    OnRowDeleting="Delete_Schedule" OnPageIndexChanging="OnPaging" OnRowEditing="Edit_Schedule"
                    OnRowCancelingEdit="CancelEdit" PageSize="10">
                                <asp:Label Text='<%# Eval("Title") %>' runat="server" ID="lbl1"></asp:Label>
                                <asp:TextBox ID="txtTitle" Text='<%# Eval("Title") %>' runat="server"></asp:TextBox>

spgridview RowDataBound event returning cell values as empty


i am working with SPGridView to display Announcements. User should be able to edit his own created Announcements.Remaining Items shouldnt be having edit option.

i created SPGridView Columns :

                SPBoundField Title = new SPBoundField();
                Title.HeaderText = "Title";
                Title.HeaderStyle.Font.Bold = true;
                Title.DataField = "Title";

                SPBoundField Description = new SPBoundField();
                Description.HeaderText = "Description";
                Description.DataField = "Description";


WPF Datagrid SelectionChanged event is triggering Multiple times while loading the rows.



When i use DataGridComboBoxColumn in my WPF DataGrid, the DataGrid SelectionChanged event is triggering multiple times based on the number of rows while loading the rows in the WPF DataGrid.

How can i stop this? Because of this I am facing Performance issue.



Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This will help other members to find the solution easily.

DataGrid ItemDataBound Event Calls


how many times itemDataBound event calls exactly, if my datatable have 2 records it is calling 4 times , first time in item index 0 , second time it is 1 and third time again it contains index 0 and forth time it is 1. 

so, could anyone please help me how the itemdatabound event actually works,

highly appreciate for any comment.

Gridview's cell have changed



   does anyone know if the gridview can tell you if a cell's contents have changed (during an edit) in order to determine if an update should be made against the database?

jquery - span text changed event


is there a jquery event that is fired when the text of a span element is changed? The change event does not apply to <span> elements. I see reference to "text changed", but $('#PriceCond').bind('textchange', function(event, prevText) { ... }) ; does not work either.



     <input type="button" id="TestButton" value="Test" />

     <span id="PriceCond"></span>

<script type="text/javascript">
  $(document).ready(function ()

    var clickFunc =
          function ()
            var s1 = $('#PriceCond').text();
            $('#PriceCond').text(s1 + 'x');

    var priceChangeFunc =
          function ()
            alert('in priceChangeFunc');





ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend