Click here to Skip to main content
15,917,608 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am assing value of data tabe to all textboxes like

C#
if (dr.HasRows)
               {
                   if (dr.Read())
                   {
                       if (dt.Rows[0][0].ToString() == String.Empty)
                       {
                           textBox1.Text = null;
                       }
                       else
                       {
                           textBox1.Text = dt.Rows[0][0].ToString();
                       }
                       if (dt.Rows[1][0].ToString() == String.Empty)
                       {
                           textBox2.Text = null;
                       }
                       else
                       {
                           textBox2.Text = dt.Rows[1][0].ToString();
                       }
                       if (dt.Rows[2][0].ToString() == String.Empty)
                       {
                           textBox3.Text = null;
                       }
                       else
                       {etc.

in database there is only two row in column

and show error on third 


i just want to compare bland or null value an d i don't know how to do this
Posted
Comments
Tom Marvolo Riddle 17-Apr-14 6:58am    
will you please explain bit more?

Bh@gyesh 17-Apr-14 7:26am    
Hi,
here you stated that, your table has only two row. so you can not check "if (dt.Rows[2][0].ToString() == String.Empty)", it will throw an error, as it check for third row but it does not exists in table. So remove that line. You can also use forloop for this operation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900