7
Answers

deduction Values

yesubabu k

yesubabu k

8y
360
1
i have a gridview in that 
 
CO_RoomRent as [Room Rent],
CO_ExtrbedAmount as [Extra Bed Amount],
CO_ExtrapersonAmount as [Extra Person Amount],
CO_TotalRoomRent as [Total Amount],
CO_TransactionAmount as [Transaction Amount]
those are the fields
now in textbox i will give discount percentage
using that percentage
deduct that percentage
display
remaining value display in gridview
 
desktop application
c#
sql server2008
please help me 
 
 
 
Answers (7)
1
Feroz Khan

Feroz Khan

NA 121 13.8k 8y
Sorry don't understand your question proper.
you want discount percentage in text box from where form datagridview column or other.
0
Feroz Khan

Feroz Khan

NA 121 13.8k 8y
Dear Yesubabu,
If you want to show value in grid view then you need to do below code.
foreach (DataGridViewRow row in dataGridView1.Rows)
{
int n = row.Index;
dataGridView1.Rows[n].Cells[6].Value =
Double.Parse(dataGridView1.Rows[n].Cells[4].Value.ToString()) /
Double.Parse(dataGridView1.Rows[n].Cells[5].Value.ToString());
}
and if you want to show value in Text Box so need to do below code.
double issue = 0;
int storedays = Convert.ToInt32(Total_StoreDays_txt.Text);
if (double.TryParse(Total_issue_txt.Text, out issue))
{
remainingvalue.Text = (TotalValue / Percentage).ToString();
}


0
Dipika

Dipika

NA 1.2k 14.6k 8y

  1. publicpartialclassDefault3:System.Web.UI.Page
  2. {
  3. SqlConnectioncon=newSqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString.ToString());
  4. protectedvoidPage_Load(objectsender,EventArgse)
  5. {
  6. con.Open();
  7. stringq="Select*fromamount";
  8. SqlCommandcmd=newSqlCommand(q,con);
  9. SqlDataReaderdr=cmd.ExecuteReader();
  10. DataTabledt=newDataTable();
  11. dt.Load(dr);
  12. DataSetds=newDataSet();
  13. ds.Tables.Add(dt);
  14. GridView1.DataSource=ds;
  15. GridView1.DataBind();
  16. }
  17. protectedvoidButton1_Click(objectsender,EventArgse)
  18. {
  19. doubletotalamount=0;
  20. doublediscount=Convert.ToDouble(TextBox1.Text);
  21. foreach(GridViewRowrowinGridView1.Rows)
  22. {
  23. totalamount=Convert.ToDouble(row.Cells[3].Text);
  24. totalamount=totalamount-(totalamount*(discount/100));
  25. row.Cells[3].Text=totalamount.ToString();
  26. }
  27. }
  28. }
  1. <formid="form1"runat="server">
  2. <div>
  3. Discountin%<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox><br/>
  4. <asp:ButtonID="Button1"runat="server"Text="Calculate"OnClick="Button1_Click"/><br/>
  5. <asp:GridViewID="GridView1"runat="server"Width="600"AutoGenerateColumns="false">
  6. <Columns>
  7. <asp:BoundFieldDataField="CO_RoomRent"HeaderText="CO_RoomRent"/>
  8. <asp:BoundFieldDataField="CO_ExtrbedAmount"HeaderText="CO_ExtrbedAmount"/>
  9. <asp:BoundFieldDataField="CO_ExtrapersonAmount"HeaderText="CO_ExtrapersonAmount"/>
  10. <asp:BoundFieldDataField="CO_TotalRoomRent"HeaderText="CO_TotalRoomRent"/>
  11. <asp:BoundFieldDataField="CO_TransactionAmount"HeaderText="CO_TransactionAmount"/>
  12. </Columns>
  13. </asp:GridView>
  14. </div>
  15. </form>
0
Dipika

Dipika

NA 1.2k 14.6k 8y
You want to change it in database or temporary basis in the grid only
0
yesubabu k

yesubabu k

NA 179 6.8k 8y
sir
rowdatabound event where is locatedin gridview property foe windows application
i did not get that after all events searched belongs gird
0
Dipika

Dipika

NA 1.2k 14.6k 8y
You will need to update that in database, the amount column value should get updated and then bind the grid
0
yesubabu k

yesubabu k

NA 179 6.8k 8y
Sir
I Have a form containing textbox(Percentage),
gridview for Displaying result gridview has Total amount column
Ex:
total amount / percentage = remaining value
it will show in gridview when i give some value automatically remaining value change then display in my gridview