I am sending CurrentPage
value 1, but it gives a null reference exception in set
.
lblCurrentPage
is a label control. CurrentPage
is one variable.
public int CurrentPage
{
get { return int.P开发者_C百科arse(lblCurrentPage.Text); }
set {
lblCurrentPage.Text = Convert.ToString(value);
}
}
You have a massive lack of info for us to go on, but i'll make a suggestion. Check that lblCurrentPage is actually set to a real control, i.e. make sure the label has been instantiated before you try to set its properties.
public int CurrentPage
{
get
{
int temp = 0;
if (lblCurrentPage != null)
{
int.TryParse(lblCurrentPage.Text, out temp);
}
return temp;
}
set
{
if (lblCurrentPage != null)
lblCurrentPage.Text = Convert.ToString(value);
}
}
精彩评论