Click here to Skip to main content
16,004,587 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
.cs code
if (!IsPostBack)
{
if (Request.Cookies["addcart"] != null)
{
bindcategory();
}
}



}

private void bindcategory()
{




rptbindcart.DataSource = sl_con.GetDatatable(@"SELECT *
FROM tblproduct_salwarsuit
WHERE (Id = " + Request.Cookies["addcart"].Value + ")", "acs");
rptbindcart.DataBind();





}

aspx code


XML
<asp:GridView ID="rptbindcart" runat="server" AutoGenerateColumns="False" BorderStyle="None" EnableModelValidation="True">
    <Columns>
        <asp:TemplateField HeaderText="Name">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("p_name") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Bind("p_name") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Image">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Eval("p_price") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Image ID="Image1" runat="server" Height="36px" ImageUrl='<%# Eval("p_img","~/Product/{0}") %>' Width="36px" />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Price">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("p_price") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label3" runat="server" Text='<%# Bind("p_price") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Quantity">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label4" runat="server"></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Total">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label5" runat="server"></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:CommandField EditText="Change" ShowEditButton="True" />
        <asp:CommandField DeleteText="Remove" ShowDeleteButton="True" />
    </Columns>




</asp:GridView>
Posted
Comments
Gihan Liyanage 29-Aug-14 4:51am    
If you can tell what you need by small description , it would be better
Gihan Liyanage 29-Aug-14 5:10am    
This question only having code, identifying the problem through the code is more difficult any developer . So if you csn describe the problem, then you will be get answer quickly.
[no name] 29-Aug-14 5:30am    
sir i am use class


using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data.SqlClient;

public static class sl_con
{
//public static string ConnectionString
//{
// get { return ConfigurationManager.ConnectionStrings["acs"].ToString(); }
//}
public static string ConnectionString(string conName)
{
if(conName=="acs")
return ConfigurationManager.ConnectionStrings["acs"].ToString();
else
return ConfigurationManager.ConnectionStrings["acsExDb"].ToString();

}
public static SqlConnection GetConnection(string conName)
{
SqlConnection con = new SqlConnection(ConnectionString(conName));
if (con.State == ConnectionState.Closed)
con.Open();
return con;
}

public static DataTable GetDatatable(string sql,string conName)
{
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(sql, ConnectionString(conName));
sda.Fill(dt);
return dt;
}

public static void ExecuteNonQuery(string sql,string conName)
{
using (SqlConnection con = GetConnection(conName))
{
SqlCommand cmd = new SqlCommand(sql, con);
cmd.ExecuteNonQuery();
}
}

public static string ExecuteScalar(string sql, string conName)
{
using (SqlConnection con = GetConnection(conName))
{
SqlCommand cmd = new SqlCommand(sql, con);
return cmd.ExecuteScalar().ToString();
}
}

}

Gihan Liyanage 29-Aug-14 5:42am    
What do you meant by repeat in the grid view ?
Gihan Liyanage 29-Aug-14 5:42am    
Do you want add two items to the cart when click the button twice ???

1 solution

 
Share this answer
 
Comments
Gihan Liyanage 15-Sep-14 6:24am    
Did you got a solution from my support, I can see you have not accepted any answer.If you are ok with this answer plz accept it. Then any user having same problem can identified it has solved the problem..

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