Tag-Archive for ◊ c# ◊

To add filter options to a gridview you can do something like this.
I’m using sqldatasource and have one dropdownlist with the Columns we want to filter and one text box with ther search criteria.

SqlDataSource1.FilterExpression = DropDownListField.SelectedValue + ” like ‘%” + TextBoxSearch.Text + “%’”;

then i save the criteria to an session variable to use in other events like paging…

enjoy:)

Portuguese Version-
Para adicionar opções para filtrar um gridview que você pode fazer algo assim.
Estou usando o SqlDataSource e uma dropdownlist com as colunas que queremos para filtrar e uma caixa de texto que existem critérios de pesquisa.

SqlDataSource1.FilterExpression = DropDownListField.SelectedValue + “like ‘%” + TextBoxSearch.Text + “%’”;

então eu salvar os critérios para uma variável de sessão para usar em outros eventos, como paginação …

Read excel file without worksheet name
Thursday, August 20th, 2009 | Author: admin

A few times we need to load data from Excel file but we don’t know the name of the worksheet.
There are many ways to do, but i like this one because don’t need to instantiating an Excel object.

C# code:

String conString = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=c:\temp\ExcelFile.xls;Extended Properties=Excel 8.0;";

OleDbConnection yourConnection = new OleDbConnection(conString);

try

{

yourConnection.Open();

DataTable sheetTable = yourConnection.GetSchema("Tables"); //get all tables

DataRow rowSheetName = sheetTable.Rows[0];

String sheetName = rowSheetName[2].ToString();

yourConnection.Close();

}

catch (Exception ex)

{

}
Enjoy :)

Hi, if you try to compile an app in a network shared folder,or on some hosts.. maybe you will get this error

ERROR:

Could not load file or assembly ‘Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0×80131417)

This error occurs because the default trust level for local machine is Full trust, but in the network share not.

So to compile your applications remotely you have to:

1. Go to Control Panel -> Adiministrative Tools -> Microsoft .NET Framework 2.0 Configuration

2. Open My Computer -> Runtime Security Policy -> Machine -> Code Groups -> All Code ->New

the URL field in the next figure is the path to the shared folder , in this case, but you can choose Strong Names( for .exe or .dll) etc


 

 

 

 

 

 

 

 

 

 

Click Finish and you can compile your app!!
I hope this article help you…