Archive for ◊ August, 2009 ◊

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 …

textbox numeric validation
Monday, August 24th, 2009 | Author: admin

Works in Firefox and IE7, IE8
in code-behind put add this attribute to yout textbox
yourTextBox.Attributes.Add("onkeypress", "var key; if(window.event){ key = event.keyCode;}else if(event.which){ key = event.which;} return (key == 45 || key == 13 || key == 8 || key == 9 || key == 189 || (key >= 48 && key <= 58) )");

Firefox recognize event.wich :)

Estudo de Mercado
Thursday, August 20th, 2009 | Author: admin

Category: Uncategorized  | Tags: , ,  | Leave a Comment
SQL Dumper - exportar/importar scripts
Thursday, August 20th, 2009 | Author: admin
english text scroll down please:)
Não seria bom poder gerar um script de insert com dados de uma tabela do SQL Server?
Para mim seria e foi muito bom ter encontrado este pequeno mas muito útil aplicativo.
Chama-se SQL Server Dumper.
Este aplicativo permite, exportar (e gerar os scripts para inserção) de várias tabelas em vários ou num único
ficheiro .sql :)
Mas para mim o mais útil é permitir exportar os dados de uma determinda query, e não ser a tabela por inteiro como outros aplicativos:)
Se quiserem experimentar( é freeware :):) ) é só clicar aqui.

It would be good to generate a script to insert a table with data from SQL Server?
For me it was very good and have found this small but very useful application.
It is called SQL Server Dumper.

This application allows to export (and generate the scripts for integration) of multiple tables in a single or multiple
file. sql:)

But for me the most useful is to export the data from a query determinda, and not the entire table by other applications such as:)

If you want to try (it’s freeware:):)) just click here.

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 :)