StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
string DataString = RenderPartialViewToString("_OrderDetails", model);
string EncodedString = Server.HtmlEncode(DataString);
i just found the solution
it is very simple
hw.write(DataString);