Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi this is my code


C#
adp = new SqlDataAdapter("select tenderamount from tender", con);
       ds = new DataSet();
       adp.Fill(ds, "tender");
       if (ds.Tables["tender"].Rows.Count > 0)
       {
           if (TextBox5.Text > ds.Tables["tender"].Rows[0][1].ToString())
           {
               Response.Redirect("Payment.aspx?BidAmount=" + TextBox5.Text + "&TenderName=" + DropDownList1.Text);
           }
           else
           {
               Label3.Text = "sorry Your bid amount is low";
           }
       }



i want to compare the data form textbox and table value in sql then only it will redirect to new page, pls help me, i wnt to finsh it now
Posted
Updated 8-Mar-11 22:59pm
v2
Comments
m@dhu 9-Mar-11 5:06am    
Are you getting any error. Did you check AlbinAbel's answer.

1 solution

if (TextBox5.Text > ds.Tables["tender"].Rows[0][1].ToString()). You are comparing two string with > operator. This may not work well.

If those values are numbers then use

if (Convert.ToInt32(TextBox5.Text) > Convert.ToInt32(ds.Tables["tender"].Rows[0][1].ToString()))
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 9-Mar-11 15:32pm    
I would question string ordering in principle. Why doing that? You code with Convert may be not better as we don't know the purpose. ToInt32 can also through exception; who knows how to interpret it. I suspect the question simply makes no sense, re-thinking of approach is needed, not the answer as such.
(I did not vote this time.)
--SA

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