Tuesday, July 17, 2012

Parameterizing javascript functions in template fields

<a id="A4" runat="server" href="#" onclick='<%# "javascript:YourFunctionName(" + Eval("Col1") + ",\"" + Eval("Col2") + "\")" %>'><%# Eval("Col3") %> </a>

Thursday, May 12, 2011

BulkImport of Excel File/Flat File/CSV file into SQL Server Database

Below code snippet is to import data from Excel to a Dataset

string strExcelFilename = txtExcelFilename.Text;
//Use Microsoft JET OLEDB Provider

string strConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + @"Data Source=" + strExcelFilename + ";" + @"Extended Properties=" + Convert.ToChar(34).ToString() + @"Excel 8.0;HDR=YES" + Convert.ToChar(34).ToString();

OleDbConnection objCon = new OleDbConnection(strConnectionString);

try
{
objCon.Open();

//By default spreadsheet first sheet will be sheet1 unless it is renamed
string strExcelSheetName = "ExcelSheetName";

string strSQL = "SELECT * FROM [" + strExcelSheetName + "$" + "]";
OleDbDataAdapter objoleAdapter = new OleDbDataAdapter(strSQL, objCon);
objoleAdapter.Fill(ds, "tblImportedData");

SqlBulkCopy bulkCopy = new SqlBulkCopy("Server=ServerName;Database=test;Trusted_Connection=True;",SqlBulkCopyOptions.TableLock); bulkCopy.DestinationTableName = "Destination Table Name";

bulkCopy.WriteToServer(ds.Tables[0]);
}
catch (Exception ex)
{
       Response.Write(ex.Message);
       return;
}

Thursday, April 21, 2011

Useful URL convering the topics like Google SEO,WebmasterWorld Supporters, Social Media, Facebook, Marketing,Twitter,JavaScript and AJAX, HTML, CSS, Databases, Content Management,RSS,ATOM and Related Technologies, Blogging SEO, Blog Software and Blog Administration,Marketing and BizDev, Sitemaps, Meta Data, and robots.txt and many more at http://www.webmasterworld.com/home.htm




Monday, April 18, 2011

How to print a DIV content from a HTML table


Javascript function for printing DIV content from ASP.NET/PHP/ any HTML, etc.

function CallPrint(strid)

{
var prtContent = document.getElementById(strid);
window.document.write(prtContent.innerHTML);
window.document.close();
window.print();
history.back();
}

Call the javascript function as
    OnClientClick="CallPrint('divPrintMessages')"
Hope this will help you....