You should add a new property to the web part, then you can set the value for that property in SetupControl method. It worked correctly to me.
public string wpID
{
get
{
return ValidationHelper.GetValue(GetValue("wpID"), "");
}
set { SetValue("wpID", value); }
}
protected void SetupControl()
{
if (StopProcessing)
{
repItems.StopProcessing = true;
}
else
{
wpID = Guid.NewGuid().ToString();
...
}
}
Or you can try this:
wpID = this.ClientID;