John Champion
John Champion

Reputation: 147

How Can I Divide Two Field In SharePoint With Visual Studio C#

i want to divide 2 field in SharePoint using visual studio c#. I have the code as shown below

SPView vw = jobDef.View["All items"];
vW.ViewFields.Add("MinSalary");
vW.ViewFields.Add("MaxSalary");
vW.ViewFields.Add("AvgSalary");
vw.InLineEdit = "TRUE";
vw.update();


SPListItem newDef;
newDef = jobDef.Items.Add();
newDef["MinSalary"] = "40000";
newDef["MaxSalary"] = "80000";
newDef["AvgSalary"] = int.Parse("MaxSalary")/ int.Parse(MinSalary); // i dont know how what to do here

anyone help me please!

Upvotes: 0

Views: 57

Answers (1)

roemel
roemel

Reputation: 3297

I'm not 100% sure if this is what you're trying to do. But you could try the following:

int avgSalary = Convert.ToInt32(newDef["MaxSalary"]) / Convert.ToInt32(newDef["MinSalary"]);
newDef["AvgSalary"] = avgSalary.ToString();

Upvotes: 1

Related Questions