Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Plain Text by Deepak Rajput ( 13 years ago )
<%@ Page Title="" Language="C#" MasterPageFile="~/usersubMasterPage.master" AutoEventWireup="true" CodeFile="subject_list.aspx.cs" Inherits="subject_list" %>

<asp Content ID="Content1" C Runat="Server">
<br />
<div align=center>Category Name : <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div>
    <asp:ListView ID="ListView1" runat="server" GroupItemCount=2 
          
          
         >
    <LayoutTemplate>
<table border=0 cellpadding=0 cellspacing=2 width=90% align=center>
<tr id="groupplaceholder" runat=server>
<td ></td>
</tr>

</table>
    
    
    </LayoutTemplate>
    <GroupTemplate>
    <tr>
    <td id="itemplaceholder" runat=server></td>
    </tr>
    </GroupTemplate>
    <ItemTemplate>
    <td align=center valign=top>
    <div >
    <a >'>
        <asp:Image ID="Image1" runat="server" Width="170" /></a>
    </div>
<a >'>
       <%#DataBinder.Eval&#40;Container,"dataitem.subcat_name"&#41; %></a>

    </td>
    
    </ItemTemplate>
    </asp:ListView>
    <div align=center>    <asp:DataPager ID="DataPager1" runat="server" PagedC PageSize=5>
        <Fields>
        <asp:NumericPagerField />
        </Fields>
        </asp:DataPager>
  </div>
</asp:Content>
----------------------------------------------------------------
<style type="text/css">
        .productItem
        {
            width: 140px;
            float: left;
            padding: 5px;
            margin: 5px;
            text-align: center;
        }
        .groupSeparator
        {
            border-top: 1px dotted Gray;
            height: 1px;
            clear: both;
        }
        .itemSeparator
        {
            height: 180px;
            width: 1px;
            border-left: 1px dotted Gray;
            margin-top: 5px;
            margin-bottom: 5px;
            float: left;
        }
    </style>
 
    <asp:ListView runat="server" ID="listView" GroupItemCount="3">
        <LayoutTemplate>
            <div  500px;">
                <asp:PlaceHolder runat="server" ID="groupPlaceHolder" />
            </div>
        </LayoutTemplate>
        <GroupTemplate>
            <div  both;">
                <asp:PlaceHolder runat="server" ID="itemPlaceHolder" />
            </div>
        </GroupTemplate>
        <ItemTemplate>
            <div class="productItem">
                <div>
                    <img >'
                        height="120" width="120" />
                </div>
                <div>
                    <b>
                        <%# Eval&#40;"Name"&#41; %></b></div>
                <div>
                    Price: $<%# Eval&#40;"Price"&#41; %></div>
            </div>
        </ItemTemplate>
        <ItemSeparatorTemplate>
            <div class="itemSeparator">
            </div>
        </ItemSeparatorTemplate>
        <GroupSeparatorTemplate>
            <div class="groupSeparator">
            </div>
        </GroupSeparatorTemplate>
        <EmptyDataTemplate>
        </EmptyDataTemplate>
    </asp:ListView>


___________________________________
  protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Connection_String_Here");
            conn.Open();
            SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Products", conn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            conn.Close();
 
            listView.DataSource = dt;
            listView.DataBind();
        }_____________________________________________________
WDA CODE:
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;

public partial class subject_list : System.Web.UI.Page
{
    SqlConnection con;
    SqlDataAdapter ad;
    DataSet ds;
    string r;
    SqlDataAdapter ad1;
    DataSet ds1;
    ListViewItem lt;
    Image img;
  
    protected void Page_Load(object sender, EventArgs e)
    {
        string s = ConfigurationManager.ConnectionStrings["categoryConnectionString"].ConnectionString;
        con = new SqlConnection(s);
        if (Request.QueryString["r"] != null)
            r = Request.QueryString["r"].ToString();
       ad = new SqlDataAdapter("select * from subjects where cat_code='" + r + "'", con);
        ds = new DataSet();
        ad.Fill(ds);
        ad1 = new SqlDataAdapter("select * from category where catcode='" + r + "'", con);
        ds1 = new DataSet();
        ad1.Fill(ds1);
        Label1.Text = ds1.Tables[0].Rows[0]["catname"].ToString();
        ListView1.DataSource = ds.Tables[0];
        ListView1.DataBind();

    }
    protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        lt = e.Item;
        img = lt.FindControl("Image1") as Image;
        ListViewDataItem di = e.Item as ListViewDataItem;
        DataRowView dv = di.DataItem as DataRowView;
        if (System.IO.File.Exists(Server.MapPath("images/") + dv["image"].ToString()))
        {
            img.ImageUrl = "images/" + dv["image"].ToString();
        }
   
    }
    protected void ListView1_PreRender(object sender, EventArgs e)
    {
        ListView1.DataBind();

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

    }
}

 

Revise this Paste

Parent: 65245
Your Name: Code Language: