Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class crudoperations : System.Web.UI.Page
{

        inventoryDataContext obj = new inventoryDataContext();


    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnDisplay_Click(object sender, EventArgs e)
    {
        //displaying the product information based onn the entered by user with in textbox1
        var result = from p in obj.products
                     where p.prodid=txtprodid.Text*************here iam getting the error******
                     select p;
        if (result.Count() == 0)
            Response.Write("<h1>no products</h1>");
        else
        {
            foreach (var pp in result)
            {
                txtProddesc.Text = pp.proddesc;
                txtPrice.Text = pp.price.ToString() ;
            }
        }
    }
}
...



here iam getting an error cannot implicitly convert type bool to string can any one help me ,... how to rectify it
Posted

Corrected code

C#
var result = from p in obj.products
                    where p.prodid==Convert.ToBoolean(txtprodid.Text.Trim())//Corrected here
                    select p;


Use a checkbox instead of a textbox here
Quote:
txtprodid.Text.Trim()
 
Share this answer
 
v2
SQL
var result = from p in obj.products
                     where p.prodid=txtprodid.Text*************here iam getting the error******
                     select p;


Needs to be:
SQL
var result = from p in obj.products
                     where p.prodid==txtprodid.Text
                     select p;


Notice the == is equality...
 
Share this answer
 

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