crazydevelopervish 0 Light Poster

i have one datalist having shopping cart table which retrieves values as per customer_id

aspx code.

            <asp:DataList ID="DataList1" runat="server" DataKeyField="Customer_Product" 
        DataSourceID="SqlDataSource2" onupdatecommand="DataList1_UpdateCommand" 
        oneditcommand="DataList1_EditCommand1" 
        ondeletecommand="DataList1_DeleteCommand" 
                oncancelcommand="DataList1_CancelCommand1">
        <HeaderTemplate>  
    <table border="solid 1px black">  
        <tr>  
            <th style="width: 250px">  

            </th>  
            <th style="width: 400px">  
                Item Description  
            </th> 
            <th style="width: 100px">  
                Price
            </th> 
            <th style="width: 100px">  
                Qty
            </th>  
            <th style="width: 100px">  
                Remove
            </th>  
                <th style="width: 100px">  
                Total
            </th>  
        </tr>  
</HeaderTemplate> 
        <ItemTemplate>
         <tr>  
        <td> 
            <asp:Image ID="Image1" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Product_Image") %>' Width="100px" Height="150px" />  
        </td>  
        <td>  
            <%# DataBinder.Eval(Container.DataItem, "Item_Description") %>  
        </td>  
        <td>  
            <%# DataBinder.Eval(Container.DataItem, "Price") %>  
        </td>  
        <td>  
            <%# DataBinder.Eval(Container.DataItem, "Qty") %>  
            <br />
                                            <asp:LinkButton ID="lnkEdit"   
                runat="server"   
                CommandName="edit">  
                Change  
            </asp:LinkButton>  

        </td>  
        <td>  
            <asp:LinkButton ID="LinkButton1"   
                runat="server"   
                CommandName="delete">  
                Delete
            </asp:LinkButton>  
        </td>  
       <td>
           <asp:Label ID="Label2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Total") %>  '></asp:Label></td>
    </tr>  
        </ItemTemplate>
        <EditItemTemplate>  
    <tr>  
        <td>  
            <asp:Image ID="Image2" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Product_Image") %>' Width="100px" Height="150px" />  
        </td>
        <td>  
             <%# DataBinder.Eval(Container.DataItem, "Item_Description") %>  
        </td>
        <td>
        <asp:Label ID="price" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Price") %> '></asp:Label> 
        </td>  
        <td>  
           <asp:TextBox ID="TextBox1"   
                runat="server"   
                Text='<%# DataBinder.Eval(Container.DataItem, "Qty") %>'>
            </asp:TextBox>  

            <asp:LinkButton ID="lnkUpdate"   
                runat="server"   
                CommandName="Update">  
                Update  
            </asp:LinkButton>  
            <asp:LinkButton ID="lnkCancel"   
                runat="server"   
                CommandName="cancel">  
                Cancel  
            </asp:LinkButton>  
        </td>  
            <td></td>
    </tr>  
</EditItemTemplate>  
<FooterTemplate>  
    </table>  
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</FooterTemplate> 
    </asp:DataList>
     <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
         ConnectionString="<%$ ConnectionStrings:OnlineShopConnectionString2 %>" 

            SelectCommand="SELECT * FROM [Cart1] WHERE ([Customer_ID] = @Customer_ID)" 
         UpdateCommand="UPDATE [Cart1] SET [Qty] = @Qty,[Total]=@Total WHERE [Customer_Product] = @original_C_P"

         DeleteCommand="delete from [Cart1] WHERE [Customer_Product] = @original_C_P" >
         <SelectParameters>
             <asp:QueryStringParameter Name="Customer_ID" QueryStringField="name" 
                 Type="Int32" />
         </SelectParameters>
         <DeleteParameters>
          <asp:Parameter Name="original_C_P" Type="String" />
         </DeleteParameters>
        <UpdateParameters>
           <asp:Parameter Name="Qty" Type="String" />
           <asp:Parameter Name="Total" Type="String" />


           <asp:Parameter Name="original_C_P" Type="String" />
        </UpdateParameters></asp:SqlDataSource>

and using edit delete …

crazydevelopervish 0 Light Poster

Yes i have tried it ... SQL management studio shows 10 records belong to customer_id=9 but show only 9 records in datalist

crazydevelopervish 0 Light Poster

my aspx code

   <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:DataList ID="DataList1"
        runat="server" DataSourceID="SqlDataSource1" 
>
        <ItemTemplate>
            Product_Image:
            <asp:Label ID="Product_ImageLabel" runat="server" 
                Text='<%# Eval("Product_Image") %>' />
            <br />
            Item_Description:
            <asp:Label ID="Item_DescriptionLabel" runat="server" 
                Text='<%# Eval("Item_Description") %>' />
            <br />
            Price:
            <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' />
            <br />
            Qty:
            <asp:Label ID="QtyLabel" runat="server" Text='<%# Eval("Qty") %>' />
            <br />
            Total:
            <asp:Label ID="TotalLabel" runat="server" Text='<%# Eval("Total") %>' />
            <br />
            <br />
        </ItemTemplate>
    </asp:DataList>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:OnlineShopConnectionString2 %>" 

        SelectCommand="SELECT [Product_Image], [Item_Description], [Price], [Qty], [Total] FROM [Cart1]">
    </asp:SqlDataSource>

My .cs file
on button click

    SqlConnection con = new SqlConnection();
    con.ConnectionString = "Data Source=HP-HP\\SQLEXPRESS;Initial Catalog=OnlineShop;Persist Security Info=True;User ID=sa;Password=rane@1234";
    con.Open();
    SqlCommand cmd1 = new SqlCommand("select * from Cart1", con);
    SqlDataReader dr1 = cmd1.ExecuteReader();
    dr1.Close();
    SqlCommand cmd2 = new SqlCommand("select * from Cart1 where Customer_ID='" + TextBox1.Text+ "'", con);
    SqlDataReader dr2 = cmd2.ExecuteReader();

    if (dr2.Read())
    {
        DataTable dt = new DataTable();
        dt.Load(dr2);
        DataList1.DataSourceID = null;
        DataList1.DataSource = dt;
        DataList1.DataBind();
    }

now the problem when i search for the product based on customer_id given from textbox it retrives 1 record less that two starting record.
For example if i enter 9 it retrives the record from database whose customer_id is 9 but if the customer have buy 10 products it only show 9.

Pls Help

crazydevelopervish 0 Light Poster
it returns only Customer_ID
crazydevelopervish 0 Light Poster

not working geting error after including
string keys fixed[]=DataList1.DataKeys[e.Item.ItemIndex].ToString().Split(',');

Error 559 The type of a local declared in a fixed statement must be a pointer type

crazydevelopervish 0 Light Poster

and then how can i retrive value from it.....
general code is as follows...

DataList1.DataKeyField = "Customer_ID,Product_ID";
String Product_ID = DataList1.DataKeys[e.Item.ItemIndex].ToString();
String Customer_ID = DataList1.DataKeys[e.Item.ItemIndex].ToString();

crazydevelopervish 0 Light Poster

Is it possible to set two DataKeyField in DataList...........
If yes then pls help me out...................

crazydevelopervish 0 Light Poster

Its so simple why didnt it clicked me.....
looks like i was making it look difficult by myself....thanks JorgeM

crazydevelopervish 0 Light Poster

Paste code please.......

crazydevelopervish 0 Light Poster

I have one datalist which retrives record from database based of Customer_ID

<asp:DataList ID="DataList1" runat="server" DataKeyField="Customer_ID" 
            DataSourceID="SqlDataSource1" onupdatecommand="DataList1_UpdateCommand" 
            oneditcommand="DataList1_EditCommand1" 
            ondeletecommand="DataList1_DeleteCommand" 
                    oncancelcommand="DataList1_CancelCommand1">
            <HeaderTemplate>  
        <table>  
            <tr>  
                <th style="width: 250px">  

                </th>  
                <th style="width: 400px">  
                    Item Description  
                </th> 
                <th style="width: 100px">  
                    Price
                </th> 
                <th style="width: 100px">  
                    Qty
                </th>  
            </tr>  
    </HeaderTemplate> 
            <ItemTemplate>
             <tr>  
            <td> 
                <asp:Image ID="Image1" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Product_Image") %>' Width="100px" Height="150px" />  
            </td>  
            <td>  
                <%# DataBinder.Eval(Container.DataItem, "Item_Description") %>  
            </td>  
            <td>  
                <%# DataBinder.Eval(Container.DataItem, "Price") %>  
            </td>  
            <td>  
                <%# DataBinder.Eval(Container.DataItem, "Qty") %>  
            </td>  
            <td>  
                <asp:LinkButton ID="lnkEdit"   
                    runat="server"   
                    CommandName="edit">  
                    Change  
                </asp:LinkButton>  
            </td>  
            <td>  
                <asp:LinkButton ID="LinkButton1"   
                    runat="server"   
                    CommandName="delete">  
                    Delete
                </asp:LinkButton>  
            </td>  
        </tr>  
            </ItemTemplate>
            <EditItemTemplate>  
        <tr>  
            <td>  
                <asp:Image ID="Image2" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Product_Image") %>' Width="100px" Height="150px" />  
            </td>
            <td>  
                 <%# DataBinder.Eval(Container.DataItem, "Item_Description") %>  
            </td>
            <td>  
                 <%# DataBinder.Eval(Container.DataItem, "Price") %>  
            </td>  
            <td>  
               <asp:TextBox ID="TextBox1"   
                    runat="server"   
                    Text='<%# DataBinder.Eval(Container.DataItem, "Qty") %>'>
                </asp:TextBox>  
            </td>  
            <td>  
                <asp:LinkButton ID="lnkUpdate"   
                    runat="server"   
                    CommandName="update">  
                    Update  
                </asp:LinkButton>  
                <asp:LinkButton ID="lnkCancel"   
                    runat="server"   
                    CommandName="cancel">  
                    Cancel  
                </asp:LinkButton>  
            </td>  
        </tr>  
    </EditItemTemplate>  
    <FooterTemplate>  
    <td>
        </table>  
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </FooterTemplate> 
        </asp:DataList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
             ConnectionString="<%$ ConnectionStrings:OnlineShopConnectionString2 %>" 
                SelectCommand="SELECT [Customer_ID] ,[Product_Image], [Item_Description], [Price], [Qty] FROM [Cart]"
             UpdateCommand="UPDATE [Cart] SET [Qty] = @Qty WHERE [Customer_ID] = @original_CustomerID"
             DeleteCommand="delete from [Cart] WHERE [Customer_ID] = @original_CustomerID and [Product_Image]=@Product_Image" >
             <DeleteParameters>
             <asp:Parameter Name="Qty" Type="String" />
             <asp:Parameter Name="Product_Image" Type="String" />

              <asp:Parameter Name="original_CustomerID" Type="Int32" />
             </DeleteParameters>
            <UpdateParameters>
               <asp:Parameter Name="Qty" Type="String" />

              <asp:Parameter Name="original_CustomerID" Type="Int32" />
            </UpdateParameters></asp:SqlDataSource>

Suppose for example the user has buyed 6 products .......
prices such as 100,200,340,768,977,876
I want to get total of all this in a label which is in footer
How can …

crazydevelopervish 0 Light Poster

Thanks a lot JorgeM....
Really appreciate your help.....

crazydevelopervish 0 Light Poster

Its not working and i want to disable label and enable textbox dont want to assign any text to textbox.......

crazydevelopervish 0 Light Poster

On Click event of linkbutton i cannot find textbox1 and linkbutton1 because its in datalist.......... Its not that simple........

crazydevelopervish 0 Light Poster

I have one form having One DataList In which i have two table one having Header Template and other having Item Template.......

Code Of aspx page is as follows.....

    <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">

            <HeaderTemplate>
        <div>
            <table>
                <tr>

                    <td style="width:245px; text-align:center;">
                        Image</td>
                    <td style="width:450px;text-align:center;">
                        Item Description</td>
                    <td style="width:260px;text-align:center;">
                        Price</td>
                    <td style="width:322px;text-align:center;">
                        Qty</td>
                    <td style="width:300px;text-align:center;">
                        Remove</td>
                    <td style="width:310px;text-align:center;">
                        Total</td>
                </tr>
            </table>
            </div>
        </HeaderTemplate>
        <ItemTemplate>
            <div>
            <table class="style1" style="border:solid 3px purple">
                <tr>
                    <td style="width:200px;border: thin ridge #FF00FF;">
                        <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Product_Image") %>' Height="100px" Width="100px" />

                        &nbsp;</td>
                    <td style="width:500px;border: thin ridge #FF00FF;">
                    <asp:Label ID="Item_DescriptionLabel" runat="server" 
                Text='<%# Eval("Item_Description") %>' />

                        &nbsp;</td>
                    <td style="width:300px;border: thin ridge #FF00FF;text-align:center;    ">
                    <asp:Label ID="PriceLabel"  runat="server" Text='<%# Eval("Price") %>' />

                        &nbsp;</td>
                    <td style="width:300px;border: thin ridge #FF00FF;">

                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                    <asp:Label ID="QtyLabel" runat="server" Text='<%# Eval("Qty") %>' />
                        <br>
                        <br></br>
                        <asp:LinkButton ID="LinkButton1" runat="server">Change</asp:LinkButton>
                        &nbsp;</br>
                        </td>
                    <td style="width:300px;border: thin ridge #FF00FF;">
                        <asp:ImageButton ID="ImageButton1" runat="server" />
                        &nbsp;</td>
                    <td style="width:300px;border: thin ridge #FF00FF;">
                        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                        &nbsp;</td>
                </tr>
            </table>
            </div>
          </ItemTemplate>
    </asp:DataList>

As you can see there is a td tag having one label,textbox and linkbutton

<td style="width:300px;border: thin ridge #FF00FF;">

                            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                        <asp:Label ID="QtyLabel" runat="server" Text='<%# Eval("Qty") %>' />
                            <br>
                            <br></br>
                            <asp:LinkButton ID="LinkButton1" runat="server">Change</asp:LinkButton>
                            &nbsp;</br>
                            </td>

Now on this LinkButton click i want to make visibility of textbox to true bydefault it will be false and also the linkbutton text to Save............

cs file code............

        if (Session["Customer_ID"] == null)
        {
            Response.Redirect("LogIn.aspx");
        }
        else
        {
            string id = Session["Customer_ID"].ToString();
            SqlConnection con = new SqlConnection();
            con.ConnectionString = "Data Source=HP-HP\\SQLEXPRESS;Initial Catalog=OnlineShop;Persist …
crazydevelopervish 0 Light Poster

I have Table named Product Have Fields as
Prod_ID int
Prod_Name varchar(50)
Price int
Image varchar(50)----save as url

I have form which have one DropDownList Having Boung To Prod_ID Coloum it shows all the data from prod_Id coloumn
and have one gridview...
if user selects prod_ID from dropdown then it should retrive Prod_Name, Price and Image from database for that particular prod_id and display it in Gridview....

Default.aspx looks as follows....

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
            DataSourceID="SqlDataSource1" DataTextField="Prod_Id" DataValueField="Prod_Id">
        </asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:OnlineShopConnectionString %>" 
            SelectCommand="SELECT [Prod_Id] FROM [Product]"></asp:SqlDataSource>

        <asp:GridView ID="GridView1"
            runat="server">
        </asp:GridView>
    </div>
    </form>
</body>
</html>

and Default.aspx.cs looks as follows....

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;
using System.Data.SqlClient;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        SqlConnection con = new SqlConnection();
        con.ConnectionString = "Data Source=HP-HP\\SQLEXPRESS;Initial Catalog=OnlineShop;Persist Security Info=True;User ID=sa;Password=rane@1234";
        con.Open();
        SqlCommand cmd = new SqlCommand("Select * from Product where Prod_Id='" + DropDownList1.Text + "'", con);
        SqlDataReader dr = cmd.ExecuteReader();

            GridView1.DataSource = dr;
            GridView1.DataBind();

    }

}









    When user selects dropdownlist value it displays the record but instead of image it shows me image url......
crazydevelopervish 0 Light Poster

I have Table named Product Have Fields as
Prod_ID int
Prod_Name varchar(50)
Price int
Image varchar(50)----save as url

I have form which have one DropDownList Having Boung To Prod_ID Coloum it shows all the data from prod_Id coloumn
and have one gridview...
if user selects prod_ID from dropdown then it should retrive Prod_Name, Price and Image from database for that particular prod_id and display it in Gridview....

Default.aspx looks as follows....

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
            DataSourceID="SqlDataSource1" DataTextField="Prod_Id" DataValueField="Prod_Id">
        </asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:OnlineShopConnectionString %>" 
            SelectCommand="SELECT [Prod_Id] FROM [Product]"></asp:SqlDataSource>

        <asp:GridView ID="GridView1"
            runat="server">
        </asp:GridView>
    </div>
    </form>
</body>
</html>

and Default.aspx.cs looks as follows....

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;
using System.Data.SqlClient;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        SqlConnection con = new SqlConnection();
        con.ConnectionString = "Data Source=HP-HP\\SQLEXPRESS;Initial Catalog=OnlineShop;Persist Security Info=True;User ID=sa;Password=rane@1234";
        con.Open();
        SqlCommand cmd = new SqlCommand("Select * from Product where Prod_Id='" + DropDownList1.Text + "'", con);
        SqlDataReader dr = cmd.ExecuteReader();

            GridView1.DataSource = dr;
            GridView1.DataBind();

    }

}









    When user selects dropdownlist value it displays the record but instead of image it shows me image url......
crazydevelopervish 0 Light Poster

I am working on a ShoppingCart....
I am keeping it simple ....
I have One DropDownList Product_Id whose values r retrived from database....
My Table have Following Fields...
Product_ID
Product_Name
Price
Image

So whenever user seelects a product_id from dropdownlist thats value gets added to the gridview which will display all fields.....

My Code Is As Follows

   SqlConnection con;
    SqlCommand cmd;
    static DataTable dt = new DataTable();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack != true)
        {
            Label1.Text = "";


            dt.Columns.Add("Prod_Id");
            dt.Columns.Add("Prod_Name");
            dt.Columns.Add("Price");
            dt.Columns.Add("Image");
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
            DataRow row;
            int x = int.Parse(DropDownList1.Text);
            con = new SqlConnection();
            con.ConnectionString = "Data Source=HP-HP\\SQLEXPRESS;Initial Catalog=OnlineShop;Persist Security Info=True;User ID=sa;Password=rane@1234";
            con.Open();
            cmd = new SqlCommand("Select * from Product where Prod_Id='" + x + "'", con);
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {

                DataRow r = dt.NewRow();
                r[0]= dr[0];
                r[1] = dr[1];
                r[2] = dr[2];
                r[3]=dr[3];
               dt.Rows.Add(r);

            }
            GridView1.DataSource = dt;
            GridView1.DataBind();
            con.Close();

    }

i am using PostBack to check wheather the load is fresh or not if its fresh then the user have to fill cart from starting else the products get added to gridview...
Now the problem is that i am not able to retrive image from database insted its showing the path of that image....

crazydevelopervish 0 Light Poster

I am working on an online project ......
i have two links on one of the page..... say home page.... having two links One Say Shirts and Other Say Casual Shirts....
So when user click on Shirts he will be shown all Shirts from Shirts Table for men and when he select Casual Shirts he will be shownall Casual Shirts from Shirts table for men.....
I am using following code...

<a href="Shirts.aspx?For=Men">Shirts</a>
<a href="Shirts.aspx?For=Men&Type=CasualShirts">Casual Shirts</a>

So when Shirts.aspx is loded i have written following code in page_Load event....

          string Type= Request.QueryString["Type"];
        string For = Request.QueryString["For"];
        SqlConnection con = new SqlConnection();
        con.ConnectionString = "Data Source=HP-HP\\SQLEXPRESS;Initial Catalog=OnlineShop;User ID=sa;password=rane@1234";
        con.Open();
        SqlCommand cmd = new SqlCommand("Select * from Shirts where ForMW='"+For+"' and Type='"+Type+"'", con);
        SqlDataReader dr = cmd.ExecuteReader();
        dt = new DataTable();
        dt.Load(dr);
        DataList1.DataSourceID = null;
        DataList1.DataSource = dt;
        DataList1.DataBind();

Now the problem is that i cannot give Both query ie...
ForMW and Type take from QueryString

  string Type= Request.QueryString["Type"];
  string For = Request.QueryString["For"];

1.Select * from Shirts where ForMW='"+For+"' becomes
1.Select * from Shirts where ForMW='Men'
2.Select * from Shirts where ForMW='"+For+"' and Type='"+Type+"'" becomes
2.Select * from Shirts where ForMW='Men' and Type='CasualShirts'

crazydevelopervish 0 Light Poster

Suppose i create one table named Price and inserted following records
Data type nchar.....

Insert into Price values('$ 100')
Insert into Price values('$ 500')
Insert into Price values('$ 600')
Insert into Price values('$ 700')
Insert into Price values('$ 800')
Insert into Price values('$ 900')
Insert into Price values('$ 1000')
Insert into Price values('$ 1100')
Insert into Price values('$ 1200')
Insert into Price values('$ 1300')
Insert into Price values('$ 1400')
Insert into Price values('$ 1500')

Now i am calling following query

Select * from Price where Price>=N'$ 0' and Price<=N'$ 500'

Then i get following records

Price
$ 100
$ 500
$ 1000
$ 1100
$ 1200
$ 1300
$ 1400
$ 1500

crazydevelopervish 0 Light Poster

Will select clause change if i use datatype nchar insted of varchar.....

crazydevelopervish 0 Light Poster

yes autopost back set to true and also database contain dollar sign and space but still cant get the result....
is the same possible with rowfilter....

crazydevelopervish 0 Light Poster

The data type is varchar....
i have used following code but its not working...

        if (rb1.Checked == true)
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = "Data Source=HP-HP;Initial Catalog=OnlineShop;Integrated Security=True";

            con.Open();
            SqlCommand cmd = new SqlCommand("Select Product_Code, Name,Brand,Price,Image from Pendrive where Price>='$ 0' and Price<='$ 500'", con);
            SqlDataReader dr = cmd.ExecuteReader();
            dt = new DataTable();
            dt.Load(dr);
            DataList1.DataSourceID = null;
            DataList1.DataSource = dt;
            DataList1.DataBind();

        }
crazydevelopervish 0 Light Poster

I want to filter records as per price
I want to retrive data from database what i have to use to retrive data a between , and or an or....
I have following code.... But it dosnt work

 protected void rb1_CheckedChanged(object sender, EventArgs e)
    {
        if (rb1.Checked == true)
        {
            DataView dv = dt.DefaultView;
            dv.RowFilter = "Price>='$ 500' Or Price <='$ 1100'";
            DataList1.DataSource = dv;
            DataList1.DataBind();
        }

    }





I want  to retrive data from database
crazydevelopervish 0 Light Poster

Thanks a lot hericles, it worked after making 2-3 changes.... thanks once again....

crazydevelopervish 0 Light Poster

its not working properly if i select nokia it shows all details but if i select both example nokia and samsung on the same page it dont show any records neither nokia nor samsung

crazydevelopervish 0 Light Poster

I am working on an online shopping project.......

I want to retrive data from database using checkbox......

For Example....
i have an mobbile form..... having all mobile records and have some filters such as search by brand, search by range etc....
let me take example of search by brand ......

In search by brand have 4 checkbox named Nokia(Checkbox1), Samsung(Checkbox2), Sony Erricson(Checkbox3) and Blackberry(Checkbox4).... such that if user selects Nokia all nokia mobiles will be shown to him... now problem is that if user selects two checkboxes such as nokia and samsung.... he cant see both he can see only one brands mobile either nokia or samsung.... please help...... mY code as follows..... Checkbox auto post back property set to true....

public partial class Mobiles : System.Web.UI.Page
{
    DataTable dt;
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection();
        con.ConnectionString = "Data Source=HP-HP;Initial Catalog=OnlineShop;Integrated Security=True";
        con.Open();
        SqlCommand cmd = new SqlCommand("Select Product_Code, Name,Brand,Price,Image from mobiles", con);
        SqlDataReader dr = cmd.ExecuteReader();
        dt = new DataTable();
        dt.Load(dr);
        DataList1.DataSourceID = null;
        DataList1.DataSource = dt;
        DataList1.DataBind();

    }

    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {

        if (CheckBox1.Checked == true)
        {
            DataView dv = dt.DefaultView;
            dv.RowFilter = "Brand='Nokia'";
            DataList1.DataSource = dv;
            DataList1.DataBind();
        }




    }
    protected void CheckBox4_CheckedChanged(object sender, EventArgs e)
    {

        if (CheckBox4.Checked == true)
        {
            DataView dv = dt.DefaultView;
            dv.RowFilter = "Brand='Blackberry'";
            DataList1.DataSource = dv;
            DataList1.DataBind();
        }

    }

    protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
    {

        if (CheckBox2.Checked == true)
        {
            DataView dv = dt.DefaultView;
            dv.RowFilter = "Brand='Sony Ericson'";
            DataList1.DataSource = …