using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
namespace ORDAN
{
/// <summary>
/// Summary description for WebForm8.
/// </summary>
public class WebForm8 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Table Table2;
private OleDbDataAdapter myDataAdapter;
private OleDbDataAdapter myDataAdapter1;
private OleDbDataAdapter myDataAdapter2;
protected System.Web.UI.WebControls.Table Table1;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private OleDbConnection myConnect=null;
protected DataTable dt=new DataTable();
protected DataTable dt1=new DataTable();
short ans;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Inetpub\\wwwroot\\ORDAN\\Tables.mdb";
myConnect = new OleDbConnection(connectionString);
myConnect.Open();
First_Fill();
// Image1.ImageUrl=@"C:\Inetpub\wwwroot\ORDAN\catalog-pic\1\Sel l_High_Strength_Super_Slim_Fluorescent_Lighting_Fixture.gif" ;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public void First_Fill()
{
Table1.CellPadding = 4;
Table1.CellSpacing = 4;
// TableCell newCell1=new TableCell();
// TableCell newCell2=new TableCell();
// TableCell newCell3=new TableCell();
// newRow.Controls.Add(newCell1);
// newRow.Controls.Add(newCell2);
// newRow.Controls.Add(newCell3);
myDataAdapter=new OleDbDataAdapter("SELECT ImageLink FROM Category ", myConnect);
myDataAdapter.Fill(dt);
myDataAdapter1=new OleDbDataAdapter("SELECT CatName,CatId FROM Category ", myConnect);
myDataAdapter1.Fill(dt1);
myConnect.Close();
//
//
TableRow newRow=new TableRow();
newRow.BackColor = System.Drawing.Color.Violet;
Table1.Controls.Add(newRow);
TableCell newCell3;
//===================Image===============================//
foreach(DataRow r in dt.Rows)
{
newCell3=new TableCell();
System.Web.UI.WebControls.Image img=new System.Web.UI.WebControls.Image();
string ImagePath=r["ImageLink"].ToString();
if(ImagePath!="")
{
img.ImageUrl=ImagePath;
img.Height=100;
img.Width=100;
newCell3.Controls.Add(img);
newCell3.VerticalAlign=VerticalAlign.Bottom;
newCell3.Attributes.Add("align","center");
newRow.Controls.Add(newCell3);
newCell3.Height =img.Height;
newRow.Height=img.Height;
}
else
{
System.Web.UI.WebControls.Label NoPic=new System.Web.UI.WebControls.Label();
NoPic.Text="NO PIC";
NoPic.Height=100;
newCell3.Controls.Add(NoPic);
newCell3.VerticalAlign=VerticalAlign.Bottom;
newCell3.Attributes.Add("align","center");
newRow.Controls.Add(newCell3);
newCell3.Height =NoPic.Height;
newRow.Height=NoPic.Height;
}
}
// //========end image==============================================//
//
TableRow newRow1=new TableRow();
newRow1.BackColor = System.Drawing.Color.LemonChiffon;
Table1.Controls.Add(newRow1);
TableCell newCell4;
// //=========================Buttons========================== =====//
foreach(DataRow r1 in dt1.Rows)
{
DataTable dt2=new DataTable();
string temp=r1["CatId"].ToString();
ans=Int16.Parse(temp);
newCell4=new TableCell();
System.Web.UI.WebControls.Button button=new System.Web.UI.WebControls.Button();
string ButtonName=r1["CatName"].ToString();
button.Text=ButtonName;
button.TabIndex=ans;
button.Click+=new System.EventHandler(this.Button_Click);
button.Width=200;
newCell4.Width=button.Width;
newCell4.Controls.Add(button);
newRow1.Controls.Add(newCell4);
newCell4.Height=30;
newCell4.Width=200;
}
// //==========end buttons=========================================//
}
private void Button_Click(object sender, System.EventArgs e)
{
short a=(((Button)sender).TabIndex);
ButtonClick b=new ButtonClick(a);
DataGrid1.DataSource=b.X();
DataGrid1.DataBind();
}
}
}
|