how to check textbox is either null or not in .net ?

Posted by Sabarimahesh under C# on 3/19/2012 | Points: 10 | Views : 7966 | Status : [Member] | Replies : 12
Guys Share The Knowledge

I having Idea To use About String.IsNull

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M



Responses

Posted by: Naraayanan on: 3/19/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Could you please explain your question?

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 3/19/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

TextBox1.Text.Trim().Length == 0

thanks


R D Patel

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/20/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi Sabarimahesh,
Can you please explain your question?

Thanks,
Rajni Shekhar

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 3/20/2012 [Member] Silver | Points: 25

Up
0
Down
Can you explain it clearly?

Thanks,
Sanjay

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/20/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi Patel28rajendra

I'm Asking Different i think so

If We Assigning Some Value to Textbox By Database..

In That Database Having the value NuLL How to Find in C#



Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/20/2012 [Member] Bronze | Points: 25

Up
0
Down
By using DBNull

Thanks,
Rajni Shekhar

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 3/20/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
using
IF (textBox1.Text == DBNull.Value)

{
//Condition
}


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Denny on: 3/27/2012 [Member] Starter | Points: 25

Up
0
Down
hi,
check this code

if(TextBox1.Text==null)
{
//code here
}

Regards,
Denny Kurian

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 3/27/2012 [Member] Silver | Points: 25

Up
0
Down
Please use DBNull to check...
Or you can use string.IsNullOrWhiteSpace

See this http://www.dotnetperls.com/isnullorwhitespace

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/27/2012 [Member] Bronze | Points: 25

Up
0
Down
Denny

Thanks MAn


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/27/2012 [Member] Bronze | Points: 25

Up
0
Down
CGN007

Thanks MAn

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Priyagoel_24 on: 8/26/2013 [Member] Starter | Points: 25

Up
0
Down
for (int i = 0; i < dt1.Rows.Count - 1; i++)
{
string check = "select name,days,months,years,hdays from inventory";// null show here
DataTable dt2 = new DataTable();
ad.Fill(dt2);
string where = "Select name,days,months,years,hdays from inventory where name = name and days = 1 and months = 1 and years = 1 and hdays = 1";
if (dt1.Rows.Count > 0)
{ }

else
{

string insert = "insert into inventory(name,days,hdays,months,years)values('" + dt1.Rows[i]["name"].ToString() + "'," + Convert.ToInt32(dt1.Rows[i]["days"]) + "," + Convert.ToInt32(dt1.Rows[i]["hdays"]) + "," + Convert.ToInt32(dt1.Rows[i]["months"]) + "," + Convert.ToInt32(dt1.Rows[i]["years"]) + ")";
SqlCommand ad2 = new SqlCommand(insert, cn);
ad2.ExecuteNonQuery();
}
}
}

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response