 ## 5 replies

Last post Oct 08, 2019 07:02 AM by samwu

• ### add formula to my code

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

• ### Re: add formula to my code

Hi Gopi.MCA,

#### Gopi.MCA

How to add * 100 for this below

Do 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`

Best regards,

Sam

MSDN Community Support
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
• ### Re: add formula to my code

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!

• ### Re: add formula to my code

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

MSDN Community Support
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
• ### Re: add formula to my code

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 + ")";

• ### Re: add formula to my code

Hi Gopi.MCA,

#### Gopi.MCA

first i take AD column then / with J then * 100 is this below code right or wrong

This 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 { new DataColumn("CustomerId"), new DataColumn("Name"), new DataColumn("Country") });