Remove duplicates in a string array
These are the followings ways, where we can filter a string array to remove the duplicates.
private static bool Match(string item)
{
bool result = (item == PreviousItem);
PreviousItem = item;
return result;
}
public static string[] NoDuplicates(string[] input)
{
PreviousItem = null;
List<string> result = new List<string>(input);
result.Sort();
result.RemoveAll(Match);
return result.ToArray();
}
To create directory on application server with ASP.NET server side code
Here is the code to creating the directory at application with ASP.NET
using System.Data;
using System.Configuration;
// We need this namespace to create directory
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string NewDir = Server.MapPath("New Folder");
// Call function for creating a directory
MakeDirectoryIfExists(NewDir);
}
private void MakeDirectoryIfExists(string NewDirectory)
{
try
{
// Check if directory exists
if (!Directory.Exists(NewDirectory))
{
// Create the directory.
Directory.CreateDirectory(NewDirectory);
}
}
catch (IOException _ex)
{
Response.Write(_ex.Message);
}
}
}
Gridview custom paging in asp.net 3.5 with SQL Server Sproc
GridView — Displays a set of data items in an HTML table. ASP.NET GridView control enables you to display, sort, page, select, and edit data.
Default gridview paging works best when you deal with limited pages. If there are more pages then, the performance suffers. In this case direct jump to desire page is a good alternative.
I have deal with a problem on GridView while working on user control (.ascx). I have a user control (.ascx) with GridView in it. I have used Stored Procedure to retrieve data. Bounding data to gridview display all the records and Default paging setting not work for me. Here Custom Paging helps me and only those database records that need to be displayed get retrieved. Using GridView Custom Paging solve the Issue for me.
Here, I am going to demonstrate a sample on GridView Custom Paging. I want to display records from two different tables depending on search pattern, let’s consider, I have student table contain sName, sAddress, ClassId and class table contain classId and ClassName. Now I want to display Name, Address and ClassName based on string pattern. Here I will get Ramdom Records based on search pattern. In this example we are going to use ASP.Net DropDownList along with ASP.Net GridView for Pagination to provide Jump To Page Number facility to the user.
Categories
- Dot Net (12)
- .Net Framework (1)
- Ajax (1)
- ASP.NET (6)
- C#.NET (3)
- Code Snippets (3)
- WCF (1)
- SQL Server (3)
- Tutorials (1)
- Video (1)




