Click here to Skip to main content
16,016,022 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
i m working on a online shopping project.in which there are two modules admin and user.in case of user i have given all the data in product category field and its shows that data but i want to use or show that data in frontend also in product details field...there is no error but also no data showing....plz help and guide me...thanx

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 ProductSubCategory : System.Web.UI.Page
{
    Cls_FF c1 = new Cls_FF();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            filldl_subcategory();
        }
    }
    public void filldl_subcategory()
    {
        DataList2.DataSource = c1.selectDS("select * from ProSubCategory WHERE ProductId='" + Session["Pro_id"] + "'");
        DataList2.DataBind();
    }

    protected void DataList2_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "details")
        {
            string _subcatid;
            _subcatid = ((Label)DataList2.Items[e.Item.ItemIndex].FindControl("lbl_subid")).Text;
            Session.Add("subcatid", _subcatid);
            Response.Redirect("ProductDetail.aspx");

        }
    }
}


Source code:-
ASP.NET
<%@ Page Title="" Language="C#" MasterPageFile="~/UserMasterPage.master" AutoEventWireup="true" CodeFile="ProductSubCategory.aspx.cs" Inherits="ProductSubCategory" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">

        .style6
        {
            width: 100%;
        }
        .style12
        {
            width: 100%;
            height: 144px;
        }
        .style13
        {
            width: 100%;
            height: 93px;
        }
        .style14
        {
            width: 100%;
            height: 49px;
        }
        .style18
        {
            width: 100%;
            height: 30px;
        }
    </style>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table align="center" cellpadding="5" cellspacing="0" class="style6">
        <tr>
            <td align="center" class="style18">
                <asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Size="Large" 
                    ForeColor="#663300" Text="Product  Details">
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:DataList ID="DataList2" runat="server" 
                    onitemcommand="DataList2_ItemCommand" RepeatColumns="2">
                    
                        <table align="center" cellpadding="5" cellspacing="0" class="style6">
                            <tr>
                                <td>
                                    <table align="center" cellpadding="5" cellspacing="0" class="style6">
                                        <tr>
                                            <td align="center" class="style9">
                                                <asp:ImageButton ID="ImageButton2" runat="server" CommandName="Details" 
                                                    Height="112px" ImageUrl='<%# Eval("Image") %>' PostBackUrl="~/GemsDetails.aspx" 
                                                    Width="137px" />
                                            </td>
                                            <td align="left">
                                                <table align="center" cellpadding="5" cellspacing="0" class="style6">
                                                    <tr>
                                                        <td align="center">
                                                            <asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Names="Vani" 
                                                                ForeColor="#FF9900" Text='<%# Eval("SubCategoryName") %>'>


[edit] Code from comment copied here - Nelek [/edit]
Posted
Updated 17-Apr-12 5:41am
v3
Comments
kishore sharma 12-Apr-12 6:46am    
can you post code if you can.
coolyogesh 17-Apr-12 6:22am    
yep here you are...rply must...waiting for your rply...!!!!

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 ProductSubCategory : System.Web.UI.Page
{
Cls_FF c1 = new Cls_FF();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
filldl_subcategory();
}
}
public void filldl_subcategory()
{
DataList2.DataSource = c1.selectDS("select * from ProSubCategory WHERE ProductId='" + Session["Pro_id"] + "'");
DataList2.DataBind();
}

protected void DataList2_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "details")
{
string _subcatid;
_subcatid = ((Label)DataList2.Items[e.Item.ItemIndex].FindControl("lbl_subid")).Text;
Session.Add("subcatid", _subcatid);
Response.Redirect("ProductDetail.aspx");

}
}
}


Source code:-
<%@ Page Title="" Language="C#" MasterPageFile="~/UserMasterPage.master" AutoEventWireup="true" CodeFile="ProductSubCategory.aspx.cs" Inherits="ProductSubCategory" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">

.style6
{
width: 100%;
}
.style12
{
width: 100%;
height: 144px;
}
.style13
{
width: 100%;
height: 93px;
}
.style14
{
width: 100%;
height: 49px;
}
.style18
{
width: 100%;
height: 30px;
}
</style>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table align="center" cellpadding="5" cellspacing="0" class="style6">
<tr>
<td align="center" class="style18">
<asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Size="Large"
ForeColor="#663300" Text="Product Details">
</td>
</tr>
<tr>
<td align="left">
<asp:DataList ID="DataList2" runat="server"
onitemcommand="DataList2_ItemCommand" RepeatColumns="2">
<itemtemplate>
<table align="center" cellpadding="5" cellspacing="0" class="style6">
<tr>
<td>
<table align="center" cellpadding="5" cellspacing="0" class="style6">
<tr>
<td align="center" class="style9">
<asp:ImageButton ID="ImageButton2" runat="server" CommandName="Details"
Height="112px" ImageUrl='<%# Eval("Image") %>' PostBackUrl="~/GemsDetails.aspx"
Width="137px" />
</td>
<td align="left">
<table align="center" cellpadding="5" cellspacing="0" class="style6">
<tr>
<td align="center">
<asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Names="Vani"
ForeColor="#FF9900" Text='<%# Eval("SubCategoryName") %>'>
Herman<T>.Instance 17-Apr-12 14:07pm    
what is the datatype for ProductId ?
coolyogesh 19-Apr-12 7:40am    
int
coolyogesh 23-Apr-12 3:56am    
wat abt answer???
Plz help me....waiting for your reply...!!!!!!!!!

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