How to display the Directory names in the Repeater Control
Use namespace System.IO <asp:Repeater id=’Repeater1′ runat=’server’> <ItemTemplate > <%# DataBinder.Eval(Container.DataItem, ‘Name’).ToString() %> </ItemTemplate> </asp:Repeater> VB.NET Dim dir As New DirectoryInfo(Server.MapPath(‘.’)) Repeater1.DataSource = dir.GetDirectories Repeater1.DataBind() C# DirectoryInfo dir = new DirectoryInfo(Server.MapPath(‘.’)); Repeater1.DataSource = dir.GetDirectories(); Repeater1.DataBind();
How to display alphabetically sorted data in Repeater
<asp:Repeater id=’Repeater1′ runat=’server’> <ItemTemplate > <b> <u><p> <%#GetFirstAlphabet(DataBinder.Eval(Container.DataItem, ‘LastName’).ToString())%> </p></u> </b> <%#DataBinder.Eval(Container.DataItem, ‘LastName’).ToString()%> ,<%#DataBinder.Eval(Container.DataItem, ‘FirstName’).ToString()%><br> </ItemTemplate> </asp:Repeater> VB.NET If Not Page.IsPostBack Then ’Populate the Data in the Repeater End If protected function GetFirstAlphabet(ByVal strval As String) As String Dim alphabet As String = ViewState(‘alphabet’) If alphabet = Left(strval, 1) Then Return ” Else alphabet = Left(strval, 1) ViewState(‘alphabet’) = alphabet Return alphabet End If End Function C# if(!Page.IsPostBack) { //Populate the Data in the Repeater } protected string GetFirstAlphabet(string strval) { string alphabet =(string) ViewState[‘alphabet’]; if( alphabet == strval.Substring(0,1) ) { return ”; } else { alphabet = strval.Substring(0,1); ViewState[‘alphabet’] = alphabet; return alphabet; } }
How to run a Web application using the permission of an authenticated user
Use the <identity> element in the web.config <identity impersonate=’true’/>
How to implement authentication via web.config
Include the <authorization> element. <authorization> <deny users=’?’/> </authorization>
Why do I get the Compiler Error Message: ‘CS0246: The type or namespace name ‘…’ could not be found (are you missing a using directive or an assembly reference?) ‘
This problem typically comes when: You do not have class with that name in your project You add the class later on and run the project without compiling You have the class but you do not specify the namespace via Imports or using keyword