I want to add a Custom Webpart on default.aspx. The Web Part appears on the page but not on the right place. I want the webpart on the right site and on the first place. I´m using the following Code to perform this action.
using (
SPLimitedWebPartManager webPartManager =
adminweb.GetLimitedWebPartManager(adminweb.Url + "/default.aspx", PersonalizationScope.Shared))
{
byte[] kennzahlenWebPart = Resources.Kennzahlen;
MemoryStream memory = new MemoryStream(kennzahlenWebPart);
XmlReader oxmlReader = new XmlTextReader(memory);
string errorMsg;
WebPart oWebPart = webPartManager.ImportWebPart(oxmlReader, out errorMsg);
webPartManager.AddWebPart(oWebPart, "Right", 0);
webPartManager.SaveChanges(oWebPart);
}
After that Code the Webpart always appears on the right site on the last place. I don´t know how to solve this issue. Hopefully someone can help me. Thanks in Advance.
webPartManager.AddWebPart(oWebPart, "Right", 0);
towebPartManager.AddWebPart(oWebPart, "Right", 1);
and let me know if it works.