You must Sign In to post a response.
  • Category: ASP.NET

    Need to show the data in minus in asp.net using c#

    need to show the data in minus in asp.net using c#

    in a textbox i gave a lot no it show the data in gridview. and i have a radiobutton if i click in same gridview i need to show the data in minus

    textbox1 i give 1423 it show the data as below

    productno qty mrp

    1 1 40


    if i click the radiobutton it focus in textbox1

    productno qty mrp

    1 1 40

    45 1 -20
    ---------------
    20
  • #762223
    Hi selvi,

    Your question is not clear, I request you to please elaborate your requirement clearly so that we can help you out of this issue.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #762224
    Hi

    If you need after Databind Modified Particular column means you can use this code

    After radio button select event added code which i have mention below try this code


    DataTable dtAfterCalc=new DataTable();
    dtAfterCalc = (DataTable) ViewState["Products"];

    for (int i = 0; i <= dtAfterCalc.Rows.Count - 1; i++)
    {
    dtAfterCalc.Rows[i].BeginEdit();
    dtAfterCalc.Rows[i]["MRP"] = Convert.ToDecimal(dtAfterCalc.Rows[i]["MRP"]) - Convert.ToDecimal(txtreturnbox.Text);
    dtAfterCalc.Rows[i].EndEdit();
    }
    ddsales.DataSource = dtAfterCalc;
    ddsales.DataBind();


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762226
    refer my image u got an idea

    grid.bmp

    Delete Attachment

  • #762227
    Hello Selvi,

    Share your code us, so that we can understand what wrong you are doing??

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #762240
    i does not have code i dont have idea on that .

  • #762247
    Hi

    Where you put 27? in your snapshot no there input 27 value

    I mention the code after you enter the textbox value substract and bind the grid use that code working fine
    when the enter value after select your return radio button use my code that code modified current datatable and bind in your gridview check once.

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762272
    that 27 is i add first two rows 27+27=54 now i reduce the thrid value 27 . now 54-27=27 ..

  • #762282

    Hi

    you can try this code working for me.

    Goto your method name this private void ReturnListView() after add my code this line
    txtBarcode.Focus();
    }


    DataTable dtAfterCalc=new DataTable();
    dtAfterCalc = (DataTable) ViewState["Products"];
    decimal GrdddlsalesTotal = 0;
    decimal GrdreturnstockTotal = 0;
    for (int i = 0; i <= dtAfterCalc.Rows.Count - 1; i++)
    {
    dtAfterCalc.Rows[i].BeginEdit();
    dtAfterCalc.Rows[i]["MRP"] = Convert.ToDecimal(dtAfterCalc.Rows[i]["MRP"]) - Convert.ToDecimal(txtreturnbox.Text);
    dtAfterCalc.Rows[i].EndEdit();
    GrdddlsalesTotal = GrdddlsalesTotal + Convert.ToDecimal(dtAfterCalc.Rows[i]["MRP"]);
    ViewState["VwGrdddlsalesTotal"] = GrdddlsalesTotal;
    }
    ddsales.DataSource = dtAfterCalc;
    ddsales.DataBind();




    ViewState["Productss"] = productss;

    ddreturnstock.DataSource = productss;
    ddreturnstock.DataBind();

    for (int i = 0; i <= productss.Rows.Count - 1; i++)
    {
    GrdreturnstockTotal = GrdreturnstockTotal + Convert.ToDecimal(productss.Rows[i]["MRP"]);
    ViewState["VwGrdreturnstockTotal"] = GrdreturnstockTotal;
    }





    if (productss.Rows.Count == 0)
    {
    txtBarcode.Text = "";
    txtBarcode.Focus();
    Response.Write("<script>alert('Please Enter Bill Amount !')</script>");
    }
    else if (productss.Rows.Count != 0)
    {
    // txtBarcode.Text = "";
    // txtBarcode.Focus();
    // Response.Write("<script>alert('Please Enter Bill Amount !')</script>");
    }
    else
    {
    Calculation();
    }

    decimal Total = 0;
    if (ddreturnstock.Rows.Count > 0)
    {
    decimal Grd1 =(decimal) ViewState["VwGrdddlsalesTotal"];
    decimal Grd2 = (decimal)ViewState["VwGrdreturnstockTotal"];
    Total = Grd1 - Grd2;
    txtbillamountcash.Text = Total.ToString();
    }



    I have attached Image Given Below.


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

    Delete Attachment

  • #762284
    Hello Kumar,

    Wow. You have done it. Well done.

    Hope this is the exact requirement of Selvi.

    Good. Keep going on.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #762292
    Hi

    Thanks Nirav

    for your encourage word now i feel select as a best answer. Thanks you so much.

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762378
    Hi

    If you need update particular column means try this code


    protected void txtqty_TextChanged(object sender, EventArgs e)
    {
    foreach (GridViewRow row in ddsales.Rows)
    {
    row.Cells[3].Text = txtqty.Text;
    }
    }

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


Sign In to post your comments