Google+ Peter Bromberg's .NET Blog | All Things Programming

Peter Bromberg's .NET Blog All Things Programming

How To Fix "Unable to access the IIS Metabase" error when loading Web Application in Visual Studio

23. May 2016 06:58 by admin in

When you see:

<Path to Project> : error  : The Web Application <Project Name> is configured to use IIS.  Unable to access the IIS metabase. You do not have sufficient privilege to access IIS web sites on your machine.

There is an easy fix:

Browse to C:\Windows\System32\inetsrv and then double-click the “config” directory. You should get this warning dialog:

 

Click Continue, then do the same for the C:\Windows\System32\inetsrv\config\export directory and the other directories in C:\Windows\System32\inetsrv

This should fix the issue and you will be able to load the project.

 

 

Convert DataTable to List<T>

15. March 2016 13:39 by admin in

 DataTable dt = ds.Tables[0];

             var   sponsorids  = dt.Rows.OfType<DataRow>().Select(dr => (int) dr["AccountID"]).ToList();

                return sponsorids;

Customize Url Parameters in Telerik RadGrid Hyperlink Column

28. August 2015 12:36 by admin in
<telerik:RadGrid ID="grdBlah" runat="server" AllowMultiRowSelection="false" AllowPaging="true"AutoGenerateColumns="False" CellPadding="0" GridLines="Both" PageSize="15" ShowFooter="false"OnPageIndexChanged="grdBlah_OnPageIndexChanged"AllowSorting="true"OnSortCommand="grdBlah_OnSortCommand"OnNeedDataSource="grdBlah_NeedDataSource"OnItemDataBound="grdBlah_OnItemDataBound"><MasterTableView ShowFooter="false"><Columns><telerik:GridTemplateColumn UniqueName="btnViewTransactionDetails"ItemStyle-Width="100" HeaderStyle-Width="100"HeaderText="Action"ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"><ItemTemplate><asp:HyperLink ID="HyperLink1" runat="server" Text="View Detail"NavigateUrl='<%#String.Format("~/Pages/TransactionDetails.aspx?ID={0}&accountID={1}", DataBinder.Eval(Container.DataItem,"transID")  , hfAccountID.Value) %>'></asp:HyperLink></ItemTemplate></telerik:GridTemplateColumn></Columns></MasterTableView><ClientSettings EnablePostBackOnRowClick="true"><Selecting AllowRowSelect="true" /></ClientSettings>
</telerik:RadGrid>

This example should be self-explanatory. If there are more parameters, handle them exactly as in the example code below.

 

How to get the Url to the current page in ASP.NET

24. August 2015 06:13 by admin in

There are lots of methods but I think this one is the easiest:

 

 string returnUrl = Request.Url.GetLeftPart(UriPartial.Authority);