473,563 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

check datagrid.column s value - template

10 New Member
Hello!

I have a question.

I have a DataGrid with 3 columns binding (Article Quantity,Blocke d Quantity & a template named Input quantity). i want to check the input QTY value.

for example:
Article QTY = 100
Blocked QTY = 50

I want to input the input QTY, but the maximal value of the input QTY mustn't be over 50 because Article QTY - Blocked QTY is the maximal Value. How can I check that?

Expand|Select|Wrap|Line Numbers
  1.  <DataGrid AutoGenerateColumns="False" Grid.RowSpan="2" Grid.ColumnSpan="2" Grid.Row="4" Height="160" HorizontalAlignment="Left" Name="grd_Block_pos" VerticalAlignment="Top" Width="auto">
  2.             <DataGrid.Columns>
  3.                 <DataGridTextColumn IsReadOnly="True" Width="auto" Header="Article" Binding="{Binding Article}" />
  4.                 <DataGridTextColumn IsReadOnly="True" Width="auto" Header="Product Descr1" Binding="{Binding ProdDescr1}" />
  5.                 <DataGridTextColumn IsReadOnly="True" Width="auto" Header="Article QTY" Binding="{Binding Article QTY}" />
  6.                 <DataGridTextColumn IsReadOnly="True" Width="auto" Header="Blocked QTY" Binding="{Binding Blocked_QTY}" />
  7.                 <DataGridTemplateColumn Header="input_QTY">
  8.                     <DataGridTemplateColumn.CellTemplate>
  9.                         <DataTemplate>
  10.                             <TextBox Text="{Binding input QTY}" MinWidth="50" Name="input_QTY" BorderThickness="0"/>
  11.                         </DataTemplate>
  12.                         </DataGridTemplateColumn.CellTemplate>
  13.                 </DataGridTemplateColumn>
  14.             </DataGrid.Columns>
  15.         </DataGrid>
  16.  
  17.  


If I make a LostFocus or TextChanged event on the input_QTY, I get an error:

Expand|Select|Wrap|Line Numbers
  1. Private Sub input_QTY_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles input_QTY.TextChanged
  2.  
  3.     End Sub
Error 13 Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
Can somebody help me?
Jan 24 '13 #1
5 8417
Frinavale
9,735 Recognized Expert Moderator Expert
If you want to use the TextChanged event, then keep that method but don't use "Handles". Instead, in your template, specify the function that should be called.

For example:
Expand|Select|Wrap|Line Numbers
  1. <DataGridTemplateColumn Header="input_QTY">
  2.   <DataGridTemplateColumn.CellTemplate>
  3.     <DataTemplate>
  4.       <TextBox Text="{Binding input QTY}" TextChanged="input_QTY_TextChanged" MinWidth="50" Name="input_QTY" BorderThickness="0"/>
  5.     </DataTemplate>
  6.   </DataGridTemplateColumn.CellTemplate>
  7. </DataGridTemplateColumn>

-Frinny
Jan 24 '13 #2
Mathias123
10 New Member
hi Frinny!

It works!!!!! Thx for your quick response. I like XAML :)
But the OnTextChanged dont work. In Visual Studio it is TextChanged="in put_QTY_TextCha nged"

thanks a lot!

Nice greets
Mathias
Jan 25 '13 #3
Frinavale
9,735 Recognized Expert Moderator Expert
Hehe, I'm sorry!

I thought I was answering an asp.net question.
I've modified my response to be correct.

Glad it worked for you.

-Frinny
Jan 25 '13 #4
Frinavale
9,735 Recognized Expert Moderator Expert
Mathias123, what are you binding to?
If you are binding to a class (like a view model class) you should put your validation in there.

In other words, when the user tries to change the value to something invalid...throw an exception.

You can modify your binding so that it catches exceptions and displays the TextBox with a red outline.

You can go even further and add a tooltip style for the TextBox, so that when there is an error with the data the TextBox is displaying it will be shown as a tool tip if the user hovers over it.

-Frinny
Jan 25 '13 #5
Mathias123
10 New Member
yeah thanks for the tip with the red outline... looks great! thx :)
Feb 5 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3096
by: Kiran | last post by:
Hi, How can I check whether the value entered in a textbox is numeric without doing a postback Kiran
5
11870
by: Eli | last post by:
Hi, I want to check whether a value is a scalar. A scalar can be: - None (null) - string - number (integer, float) - boolean How can I validate a value is one of these types? I care about the value only, and not its class methods.
1
10356
by: shiniskumar | last post by:
how to check if the value of a boolean variable is true of false in ftl? ive got a boolean variable whose value is false i have to perform some action based on its value in front end how do i do this?
4
3743
by: kannan1983 | last post by:
how can we check whether a value is valid year or not in oracle , please give your suggestions
173
7977
by: Marty James | last post by:
Howdy, I was reflecting recently on malloc. Obviously, for tiny allocations like 20 bytes to strcpy a filename or something, there's no point putting in a check on the return value of malloc. OTOH, if you're allocating a gigabyte for a large array, this might fail, so you should definitely check for a NULL return.
4
9203
by: theoni | last post by:
Hello all, I am using a script to export database values to xls. I am using an if statement to check if the value is numeric and has a length of ten digits. My problem is that when I extract the valaues from the the timestamp then the phone numbers whcih are also 10 digit lenthg numbers are also covnerted to dates! the numbers may only start...
4
5590
by: qwedster | last post by:
Howdy folks! I am using stored procedure to see if a value exists in database table and return 0 if exists or else -1, in the following SQL queries. However how to check if a value (that is null) exists in database table and return 0 if exists or else -1 using stored procedure? Please help. USE GO IF EXISTS (SELECT name FROM...
2
14645
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how can I pass null value as parameter to the database stored procedure programattically using C#? Although I can check for empty column (the...
3
1600
by: slenish | last post by:
Hello everyone, What im trying to do is have a form that will check for a value in a TxtBox across a network. I have a form that when creating a new record it automatically creates a new record number, but the database is running on many computers at the same time and if they all go to create a new record they will all start with the same...
0
8101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7943
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6238
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5479
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3631
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3615
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2077
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
912
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.