my design is
Billing Details | ||
AppendDataBoundItems="True" AutoPostBack="True" onselectedindexchanged="DropDownList3_SelectedIndexChanged"> | ||
onrowdatabound="GridView1_RowDataBound" Width="100px"> onselectedindexchanged="ddlw_SelectedIndexChanged"> onselectedindexchanged="DropDownList1_SelectedIndexChanged" AutoPostBack="True"> > | ||
mycode is
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;
using System.Data.SqlClient;
public partial class Admin_AddmoreProduct : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=VALUED-HO1E64NO\\SQLEXPRESS;Initial Catalog=Agri;User ID=sa;Password=watt");
DataSet ds = new DataSet();
REMO sel = new REMO();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
sno();
sg();
}
private void sno()
{
string bill = sel.getmaxid("BillNo", "cement1");
txtbillno.Text = bill.ToString();
}
void LoadData()
{
SqlConnection con = new SqlConnection("Data Source=VALUED-HO1E64NO\\SQLEXPRESS;Initial Catalog=Agri;User ID=sa;Password=watt");
SqlDataAdapter cmd = new SqlDataAdapter("select distinct brandname from demo1 where productname='"+DropDownList3.SelectedItem.Text+"'", con);
DataSet ds=new DataSet();
cmd.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
private void sg()
{
ListItem sll = new ListItem();
DropDownList3.Items.Add("Cement");
DropDownList3.Items.Add("Seed");
DropDownList3.Items.Add("Pesticide");
DropDownList3.Items.Add("Fetilizer");
DropDownList3.Items.Add(sll.ToString());
}
protected void txtbillno_TextChanged(object sender, EventArgs e)
{
// DataTable dt;
//dt="select
}
// private void prr()
//{
// int s = 0;
// DataSet ds=new DataSet();
// ListItem lim = new ListItem();
// //lim.Text = "Select";
// //lim.Value = "0";
// //DropDownList1.Items.Add(lim.ToString());
// ds = sel.GETDS("select DISTINCT name from demo");
// //DropDownList1.Items.Insert(0, new ListItem("--Select--", "0"));
// foreach (DataRow dr in ds.Tables[0].Rows)
// {
// // DropDownList1.Items.Clear();
// ListItem ss = new ListItem();
// lim.Text = dr["name"].ToString();
// lim.Value = Convert.ToString(s + 1);
// DropDownList1.Items.Add(lim.ToString());
// }
//}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
con.Open();
var ddl = (DropDownList)e.Row.FindControl("ddlw");
var name=Convert.ToString(((TextBox)e.Row.FindControl("itname")).Text);
//int CountryId = Convert.ToInt32(e.Row.Cells[0].Text);
SqlCommand cmd = new SqlCommand("select distinct weight from demo1 where brandname='"+name+"'", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
ddl.DataSource = ds;
ddl.DataTextField = "weight";
ddl.DataValueField = "weight";
//ddl.DataValueField = "StateID";
ddl.DataBind();
ddl.Items.Insert(0, new ListItem("--Select--", "0"));
// float sllv = Convert.ToSingle((TextBox)GridView1.FindControl("pprice"));
//float scv = Convert.ToSingle((DropDownList)GridView1.FindControl("DropDownList1"));
// TextBox sllv = e.Row.FindControl("pprce") as TextBox;
// DropDownList scv = e.Row.FindControl("DropDownList1") as DropDownList;
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (GridViewRow gvrow in GridView1.Rows)
{
float sllv = Convert.ToInt32(((TextBox)gvrow.FindControl("pprce")).Text);
float scv = Convert.ToInt32(((DropDownList)gvrow.FindControl("DropDownList1")).SelectedValue);
((TextBox)gvrow.FindControl("bfvata")).Text = Convert.ToString(sllv * scv);
string kishh=((TextBox)gvrow.FindControl("bfvata")).Text;
((TextBox)gvrow.FindControl("txtcc")).Text = Convert.ToString(int.Parse(kishh) * (14.5 / 100));
string kishore = ((TextBox)gvrow.FindControl("txtcc")).Text;
// ((TextBox)e.Row.FindControl("bfvata")).Text = Convert.ToString(sllv * scv);
}
}
protected void txextra_TextChanged(object sender, EventArgs e)
{
foreach (GridViewRow gvrow in GridView1.Rows)
{
float ses, sddd, pry;
string cs = ((TextBox)gvrow.FindControl("txtcc")).Text;
string hds = ((TextBox)gvrow.FindControl("bfvata")).Text;
string kish = ((TextBox)gvrow.FindControl("txtactl")).Text;
ses = float.Parse(cs);
sddd = float.Parse(hds);
//pry = float.Parse(kish);
//pry = float.Parse(kish);
pry = (ses + sddd);
((TextBox)gvrow.FindControl("txtactl")).Text = pry.ToString();
// string amam = ((TextBox)gvrow.FindControl("txtactl")).Text;
}
//foreach (GridViewRow gvrow in GridView1.Rows)
//{
// float gun = Convert.ToInt32(((TextBox)gvrow.FindControl("bfvata")).Text);
// float gs = Convert.ToInt32(((TextBox)gvrow.FindControl("txextra")).Text);
// ((TextBox)gvrow.FindControl("txtcc")).Text = Convert.ToString(gun + gs);
//}
//txtcc
}
protected void bfvata_TextChanged(object sender, EventArgs e)
{
}
protected void txtcc_TextChanged(object sender, EventArgs e)
{
}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
LoadData();
}
protected void ddlw_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (GridViewRow gvrow in GridView1.Rows)
{
var wegt = ((DropDownList)gvrow.FindControl("ddlw")).Text;
SqlCommand cmd = new SqlCommand("select price from demo1 where weight='" + wegt + "'",con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds.Tables["price"];
GridView1.DataBind();
}
i need if i choose the quantity as 25 i need the price for that particular quantity. but the data set is empty

selvi subramanianPosted Sep 17, 2013, 6:57 AM
Suthish NairPosted Sep 17, 2013, 5:56 AM
selvi subramanianPosted Sep 17, 2013, 5:53 AM
Suthish NairPosted Sep 17, 2013, 3:54 AM
selvi subramanianPosted Sep 14, 2013, 3:11 AM
Suthish NairPosted Sep 13, 2013, 8:16 AM
selvi subramanianPosted Sep 13, 2013, 6:45 AM
Suthish NairPosted Sep 13, 2013, 6:33 AM
selvi subramanianPosted Sep 12, 2013, 5:18 AM
Pankaj PandeyPosted Sep 12, 2013, 5:10 AM
i think when you are selecting 25 , it get the id og that product but you are passing the product name in query, may be this is problem, once pass productid in query and test it