Answered by:
add formula to my code
Question

User807418713 posted
Hello
How to add * 100 for this below
(row.FindControl("Label20") as Label).Text = "=PRODUCT(AB" + (dt.Rows.Count + 1).ToString() + "/J" + (dt.Rows.Count + 1).ToString()+")";
thanking you
Monday, October 7, 2019 7:35 AM
Answers

User288213138 posted
Hi Gopi.MCA,
first i take AD column then / with J then * 100 is this below code right or wrongThis depends on your requirement. If you want to splicing strings, then you can. But if you want to add, subtract, multiply and divide, then it is not possible.
You can try below code:
DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[3] { new DataColumn("CustomerId"), new DataColumn("Name"), new DataColumn("Country") }); dt.Rows.Add(1, "name1", "country1"); dt.Rows.Add(2, "name2", "country2"); dt.Rows.Add(3, "name3", "country3"); int AD = 1; int J = 1; float a = (AD + Convert.ToInt32(dt.Rows.Count + 1))/ J + Convert.ToInt32(dt.Rows.Count + 1) * 100; Label1.Text ="="+ PRODUCT(a.ToString());
Best regards,
Sam
 Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, October 8, 2019 7:02 AM
All replies

User288213138 posted
Hi Gopi.MCA,
How to add * 100 for this belowDo you mean multiplying the code below by 100?
If so, which string do you want to *100? such as "dt.Rows.Count + 1", You can try to convert it type to int, then *100.
Convert.ToInt32(dt.Rows.Count + 1)*100
If I misunderstand your requirement, please post more details information about your requirement.
Best regards,
Sam
Tuesday, October 8, 2019 2:51 AM 
User807418713 posted
Hi
I tried this
(row.FindControl("Label20") as Label).Text = "=PRODUCT(AD" + (dt.Rows.Count + 1).ToString() + "/J" + Convert.ToInt32(dt.Rows.Count + 1) * 100 + ")";
it showing after excel export
#DIV/0!
Tuesday, October 8, 2019 5:30 AM 
User288213138 posted
Hi Gopi.MCA,
Please debug your code to find out where there is a problem.
This is my test result, dt.Rows.Count =3, then "Convert.ToInt32(dt.Rows.Count + 1) * 100" is equal to 400.
Best regards,
Sam
Tuesday, October 8, 2019 6:22 AM 
User807418713 posted
Hi
This i used in convert to excel gridview
is this below code is right or wrong please let me know
first i take AD column then / with J then * 100 is this below code right or wrong
(row.FindControl("Label20") as Label).Text = "=PRODUCT(AD" + (dt.Rows.Count + 1).ToString() + "/J" + Convert.ToInt32(dt.Rows.Count + 1) * 100 + ")";
Tuesday, October 8, 2019 6:39 AM 
User288213138 posted
Hi Gopi.MCA,
first i take AD column then / with J then * 100 is this below code right or wrongThis depends on your requirement. If you want to splicing strings, then you can. But if you want to add, subtract, multiply and divide, then it is not possible.
You can try below code:
DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[3] { new DataColumn("CustomerId"), new DataColumn("Name"), new DataColumn("Country") }); dt.Rows.Add(1, "name1", "country1"); dt.Rows.Add(2, "name2", "country2"); dt.Rows.Add(3, "name3", "country3"); int AD = 1; int J = 1; float a = (AD + Convert.ToInt32(dt.Rows.Count + 1))/ J + Convert.ToInt32(dt.Rows.Count + 1) * 100; Label1.Text ="="+ PRODUCT(a.ToString());
Best regards,
Sam
 Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, October 8, 2019 7:02 AM