Sunday, January 17, 2010

databing sample code11 view

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;

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

LblMessage.Visible = false;
LblDiscount.Visible = false;

Hashtable productList = new Hashtable();
productList.Add("Soap", 12);
productList.Add("Cheese",20);
productList.Add("Pulses",60);
productList.Add("Rice",25);
productList.Add("Dry Fruits",30);
productList.Add("Detergent",25);


ProdList.DataSource = productList;
ProdList.DataTextField = "Key";
ProdList.DataValueField = "Value";

ProdList.DataBind();
TxtOrdDate.DataBind();

}
}
private string Td;
public string Today
{
get
{
Td=DateTime.Today.ToString();
return Td;
}

}
public int CalculateDiscount()
{
if ((Convert.ToInt16(TxtQauntity.Text) >= 20)&& (Convert.ToInt16(TxtQauntity.Text) <= 50)) { return 20; } else if (Convert.ToInt16(TxtQauntity.Text) >50)
{
return 30;
}
else
{
return 0;
}
}



protected void ProdList_SelectedIndexChanged(object sender, EventArgs e)
{
TxtProdName.DataBind();
TxtPrice.DataBind();
LblMessage.DataBind();
LblMessage.Visible = true;
}
protected void BtnSubmit_Click(object sender, EventArgs e)
{

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

}
protected void BtnDiscount_Click(object sender, EventArgs e)
{
//LblDiscount.Text= CalculateDiscount();
LblDiscount.DataBind();
LblDiscount.Visible = true;

}
protected void BtnAmt_Click(object sender, EventArgs e)
{
sm();
TxtAmt.DataBind();
}
protected void TxtQauntity_TextChanged(object sender, EventArgs e)
{

}
public void sm()
{
string intstr =Convert.ToString(Convert.ToInt16(TxtQauntity.Text) * Convert.ToInt16(TxtPrice.Text) - Convert.ToInt16(TxtQauntity.Text));


}
}

No comments:

Post a Comment