Converting label to string to integer in C# error
i have 3 lable controls in my ASPX page and in my codebehind
i'm getting them as follows:-
Label survid = (Label)e.Item.FindControl("surveyid");
Label percid = (Label)e.Item.FindControl("percentage");
Label linkid = (Label)e.Item.FindControl("link");
But i want to convert the percid,survid and linkid to integer in C# but no luck.
The percid here would sometime be a float for example 16.67 as below how can i get it
as a label as above convert it to double and then use it.
I want to use the values in OnItemCreated as show below but no LUCK converting it to integer and the percentage value to double
any ideas?
Thanks in advance
public void GetLinksItemCreated(object sender,DataGridItemEventArgs e)
//{
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
Label survid = (Label)e.Item.FindControl("surveyid");
Label percid = (Label)e.Item.FindControl("Allperc");
Label linkid = (Label)e.Item.FindControl("link");
//string perc = percid.Text;
//int perc1 = Convert.ToInt32(percid.ToString());
//percid.ToString();
double perc1 = 16.67;
//perc1 = Int32.Parse(perc.ToString());
int surv = Int32.Parse(survid.Text);
Response.Write(surv);
{
if (perc1 >= 16.67)
{
linkid.Text = "You've Passed";
}
else
if (perc1 < 16.67)
{
//linkid.Text = "<a href='http://bbb/NSurvey_WebAdmin/survey.aspx?surveyid=" + surv + "' style='text-decoration: underline;'><b>" + surv + "</b></a>";
linkid.Text="-";
}
}
}
}

