Render Failed when iam trying to display an external list in webpart in Sharepoint2010

Hey,

am trying to display an external List in webpart?

using below code

SPSite site = SPContext.Current.Site;

        SPWeb web = SPContext.Current.Web;

        SPView view = web.Lists["Rahul"].Views[0];

        view.Scope = SPViewScope.Default;


        string str = view.RenderAsHtml();

        Literal1.Text = str;

it works fine for a custom list, but when am trying to render an external list which is created using BCS(external Content type).

it throws “” error

Please share you thoughts?

Thanks in Advance

 

Hello SPKID,Have you been able to step through the code  to find what exception stack trace you get and at what line?Try below code and check if it works  :SPList list  = web.Lists[“Rahul”];SPListItemCollection itemColl = list.Items;

Hello SPKID,Have you been able to step through the code  to find what exception stack trace you get and at what line?Try below code and check if it works  :SPList list  = web.Lists[“Rahul”];SPListItemCollection itemColl = list.Items;