TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
selvi subramanian
NA
799
571.6k
how to multiply the value in gridview in asp.net
Sep 8 2013 7:53 AM
how to multiply the value in gridview.
this is my design
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Product"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList3" runat="server" Height="16px" Width="132px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="BillNo"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtbillno" runat="server"></asp:TextBox>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Choose">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="ItemName" DataField="Name"/>
<asp:TemplateField HeaderText="ItemName">
<ItemTemplate>
<asp:TextBox ID="itname" runat="server" Text='<%#Bind("Name")%>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:DropDownList ID="ddlw" runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="RequiredNo">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="0">Choose</asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
<asp:ListItem>9</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Productprice">
<ItemTemplate>
<asp:TextBox ID="pprce" runat="server" Text=<%#Bind("price")%>></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="beforevat">
<ItemTemplate>
<asp:TextBox ID="bfvata" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Extra">
<ItemTemplate>
<asp:TextBox ID="txextra" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CorrectPrice">
<ItemTemplate>
<asp:TextBox ID="txtcc" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ActualPrice">
<ItemTemplate>
<asp:TextBox ID="txtactl" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="VAT">
<ItemTemplate>
<asp:TextBox ID="txvat" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TotalAmount">
<ItemTemplate>
<asp:TextBox ID="txtamt" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td colspan="2">
</td>
<td>
</td>
</tr>
</table>
code 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");
REMO sel = new REMO();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadData();
}
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 * from demo",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");
//int CountryId = Convert.ToInt32(e.Row.Cells[0].Text);
SqlCommand cmd = new SqlCommand("select weight from demo" , con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
ddl.DataSource = ds;
ddl.DataTextField = "weight";
//ddl.DataValueField = "StateID";
ddl.DataBind();
ddl.Items.Insert(0, new ListItem("--Select--", "0"));
float sllv = Convert.ToInt32((TextBox)GridView1.FindControl("pprice"));
float scv = Convert.ToInt32((DropDownList)GridView1.FindControl("DropDownList1"));
((TextBox)e.Row.FindControl("bfvata")).Text = Convert.ToString(sllv * scv);
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
i need
to multiply the value in (requiredno* productprice)=beforevat
Reply
Answers (
11
)
nested datalist
Can I use other language in .net framework?