如何在gridview中显示以前的价格 [英] how to display previous price in gridview

查看:118
本文介绍了如何在gridview中显示以前的价格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  protected   void  btnadd_Click(对象发​​件人,EventArgs e)

{

string totalPid = txtcname.Text .Trim()。ToUpper()+& quot; - & quot; + txtcid.Text.Trim();
int ? InsertProductdetStatus;
objProductsPL.prodName = totalPid;
objProductsPL.productname = txtname.Text.Trim()。ToString();
objProductsPL.unitweight = Convert.ToInt32(txtunit.Text.ToString());
objProductsPL.company = txtcompany.Text.ToString();
objProductsPL.purpose =(txtpurpose.Text.Trim()。ToString()==& quot;& quot;? null :txtpurpose.Text 。修剪());
objProductsPL.producttype = ddlproducttype1.SelectedItem.Text.ToString();
objProductsPL.unitprice = Convert.ToDouble(txtunitprice.Text.ToString());
objProductsPL.productid3 = ddlctype.SelectedItem.Text.ToString();
objProductsPL.username = Session [& quot; username& quot;]。ToString();
InsertProductdetStatus = objProductsBAL.ProductidDetInsert(objProductsPL);
if (InsertProductdetStatus.Equals( 1 ))
{
ScriptManager.RegisterClientScriptBlock( this .Page, this .GetType(),& quot; UpdateDetails& quot; ,& quot;警告('详细信息已存在');& quot;, true );

}
else if (InsertProductdetStatus.Equals( 2 ))
{


ScriptManager.RegisterClientScriptBlock( this .Page, .GetType(),& quot; UpdateDetails& quot;,& quot; alert('已成功添加' );& quot;, true );
Grid();
clear();
bindRate();
}


}







在这里我添加了我的产品,没有任何问题..但我想显示以前的价格,当前价格列使用sql server..so我做什么..但它是基于产品名称..如果我输入相同的产品第二次,它会显示之前的价格列率.....请任何人帮我

解决方案

那么最简单的方法是维护表中的另一列命名为 OldPrice



在数据插入时,将价格插入价格 OldPrice 列。<​​br />
更新时,将新价格更新为价格列和价格 列值为 OldPrice 列。<​​/ blockquote>





这只是逻辑问题,

首先你需要两列第一个价格,第二个是当前价格,默认情况下前一个价格= 0;



放入康迪添加按钮事件:

1.检查产品名称是否属于gridview,如果属于,则获取第一行的当前价格并将该值放在上一个价格列中,当前价格具有当前价格价格。

列值可能相同或不同。



if(gridview [Productname] [i] == productname)

{

gridview [previousprice] [currentrow] = gridview [currentprice] [i];

}



我希望你能解决问题。



谢谢

Mohit

protected void btnadd_Click(object sender, EventArgs e)

    {

     string totalPid = txtcname.Text.Trim().ToUpper() + &quot;-&quot; + txtcid.Text.Trim();
    int? InsertProductdetStatus;
    objProductsPL.prodName = totalPid;
    objProductsPL.productname = txtname.Text.Trim().ToString();
    objProductsPL.unitweight = Convert.ToInt32(txtunit.Text.ToString());
    objProductsPL.company = txtcompany.Text.ToString();
    objProductsPL.purpose = (txtpurpose.Text.Trim().ToString()== &quot;&quot; ? null : txtpurpose.Text.Trim());
    objProductsPL.producttype = ddlproducttype1.SelectedItem.Text.ToString();
    objProductsPL.unitprice = Convert.ToDouble(txtunitprice.Text.ToString());
    objProductsPL.productid3 = ddlctype.SelectedItem.Text.ToString();
    objProductsPL.username = Session[&quot;username&quot;].ToString();
    InsertProductdetStatus = objProductsBAL.ProductidDetInsert(objProductsPL);
    if (InsertProductdetStatus.Equals(1))
    {
        ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), &quot;UpdateDetails&quot;, &quot;alert(&#39;Details Already Exist&#39;);&quot;, true);

    }
    else if (InsertProductdetStatus.Equals(2))
    {


    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), &quot;UpdateDetails&quot;, &quot;alert(&#39;Added Successfully&#39;);&quot;, true);
        Grid();
        clear();
        bindRate();
    }


}




Here I added my Product,without any problem..but i want to display previous price,current price column using sql server..so what i do..but it is based on Product Name..if I enter Same product second time,it will show the previous price column Rate.....Please Any one Help Me

解决方案

Then the most easy method would be maintaining another column in Table named as "OldPrice".

At the time of data insertion, insert the Price to both "Price" and "OldPrice" columns.
While updating, update new Price to "Price" column and "Price" column value to "OldPrice" column.


Hi,

It is just logical problem,
first you need to two column one previous price and second one is current price, by default previous price=0;

Put the condition on Addbutton event:
1. check product name it is belong to gridview or not , if it is belong then get current price of first row and put the value in previous price column and current price have current price.
may both column value same or not.

if( gridview["Productname"][i]== productname)
{
gridview["previousprice"][currentrow]= gridview["currentprice"][i];
}

I hope that you got solution of your problem.

Thanks
Mohit


这篇关于如何在gridview中显示以前的价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆