none
How display data in TextBox from LINQ to SQL Query

    Question

  • this is my query

     

    var Product = from p in salon.Products

     

    where p.Product_ID== 12

    select new { Cost = p.Agent_Price, SellingPrice = p.EXF_Price };

    i want to display Cost and SellingPrice in a textBox, TextBox1 and TextBox2

    Plz Help me

     

    Thursday, April 29, 2010 8:26 AM

Answers

  • Hi Ayal,

    You can bind the textboxes with query results.

    textBox1.DataBindings.Add("Text", Product, "Cost");
    textBox2.DataBindings.Add("Text", Product, "SellingPrice");

    Best regards,
    Alex Liang


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, May 03, 2010 7:14 AM
    Moderator

All replies

  • Hi Ayal,

    You can bind the textboxes with query results.

    textBox1.DataBindings.Add("Text", Product, "Cost");
    textBox2.DataBindings.Add("Text", Product, "SellingPrice");

    Best regards,
    Alex Liang


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, May 03, 2010 7:14 AM
    Moderator
  • Hi,

    I have same type of problem. I am developing a web application where My LINQ to SQL query returns multiple results and i need to bind those data to texboxes. 

    I tried to bind the adata but failed. Please suggest me... Thanks in advance!!

     

    Thursday, July 08, 2010 2:25 PM
  • TextBox is not used for displaying multiple values right? either bind one single value to a text box or use other controls to bind the multiple values result.

    Thursday, July 08, 2010 2:52 PM
  • Hi Meidi,

    Sorry for the incomplete description of the problem.

    Actually, the web page has multiple textboxes too. So each result retrieved from the query to be displayed to one textbox respectively. I am Linq query for retrieving the results.

    I need to bind the data to the textboxes but i dont find Databindings property in the intellisense. I have the required namespace also.

    Thanks again

    Thursday, July 08, 2010 5:06 PM