how to recognize null values or not required fileds
-
I have a Winform with some textboxes and comboboxes to search values from sqlserver, i need to recognize when my fields are empty and users dont input anything and by mean they dont need fields,and i have to know they dont want a field or this field is a null i am looking for the best way to handle null values in textboxes and comboboxes in c# thanks
-
I have a Winform with some textboxes and comboboxes to search values from sqlserver, i need to recognize when my fields are empty and users dont input anything and by mean they dont need fields,and i have to know they dont want a field or this field is a null i am looking for the best way to handle null values in textboxes and comboboxes in c# thanks
-
I think, there are no null in textbox/combobox. I check it using :
if(textBox.Text.Trim().Length == 0)
{
MessageBox.Show("TextBox is empty");
}if(comboBox.Text.Trim().Length == 0)
{
MessageBox.Show("ComboBox is empty");
}i want to know how to recognize null values or not required fileds when fileds are empty for example: u have 2 textboxes name and id ,one time u want to select DB all of members that they have no id (it means in search fields id is null field----select name, id from t1 where id = null) another time u need to select members that their id is blank----(select name from t1 where id = '';) thanks again
-
i want to know how to recognize null values or not required fileds when fileds are empty for example: u have 2 textboxes name and id ,one time u want to select DB all of members that they have no id (it means in search fields id is null field----select name, id from t1 where id = null) another time u need to select members that their id is blank----(select name from t1 where id = '';) thanks again
Yes, and stancrm gave you the answer. Just replace the MessageBox with your own logic.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
-
I have a Winform with some textboxes and comboboxes to search values from sqlserver, i need to recognize when my fields are empty and users dont input anything and by mean they dont need fields,and i have to know they dont want a field or this field is a null i am looking for the best way to handle null values in textboxes and comboboxes in c# thanks
Saeed.394 wrote:
the best way to handle null values in textboxes and comboboxes in c#
It's a trivial but very important question. I can give you some references which might help you decide upon the 'best'(as I donot even know the best way:)) way. 1. First take a look how you are going to handle null values in ADO.NET[^] 2. Noe it's time to create some controls which can handle null values[^] 3. One more vey important control which you may need is Nullable Datetime picker[^]. I even used in many places.You might need to tweak the code per your requirement. Let me know if this helps you.
Regards, Arindam Sinha MyBlog - http://arindamsinha.wordpress.com/ Please give your feedback on this message using rating.
-
I think, there are no null in textbox/combobox. I check it using :
if(textBox.Text.Trim().Length == 0)
{
MessageBox.Show("TextBox is empty");
}if(comboBox.Text.Trim().Length == 0)
{
MessageBox.Show("ComboBox is empty");
}What about:
if (String.IsNullOrEmpty(textBox.Text)) { MessageBox.Show("TextBox is empty"); }
etc.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
I have a Winform with some textboxes and comboboxes to search values from sqlserver, i need to recognize when my fields are empty and users dont input anything and by mean they dont need fields,and i have to know they dont want a field or this field is a null i am looking for the best way to handle null values in textboxes and comboboxes in c# thanks
You will probably need another control for user to signify they want a null value, ie ID |Text Box| X Search for Null ID if user enter into text box, ignore checkbox and search for ID = 'whatevertheuserenter'. If user checked the checkbox, search for ID Is Null.