Monday, October 30, 2006
Sharepoint installation
ref: http://www.microsoft.com/resources/documentation/wss/2/all/adminguide/en-us/stsc01.mspx?mfr=true
Infragistics web grid validation
The following scriptwill high light the active Row
function UltraWebGrid1_AfterRowActivateHandler(gridName, rowId){
//Add code to handle your event here.
var grid = igtbl_getGridById(gridName);
for(var i=0;i<grid.Rows.length;i++)
{
var uRow = grid.Rows.getRow(i);
uRow.Element.style.backgroundColor = 'White';
}
var uCurrentRow =igtbl_getRowById(rowId);
uCurrentRow.Element.style.backgroundColor='LightSkyBlue';
}
The following codes can be used to validated the input of the infragistics webgrid
<script language="javascript">
function IsGridValid()
{
var grid = igtbl_getGridById('UltraWebGrid1');
for(var i=0;i<grid.Rows.length;i++)
{
var uRow = grid.Rows.getRow (i);
var uCell = uRow.getCellFromKey("CategoryID");
alert(uCell.getValue());
debugger;
}
alert("In valid");
return false;
}
</script>
this.Button1.Attributes.Add("OnClick","return IsGridValid();");
function UltraWebGrid1_AfterRowActivateHandler(gridName, rowId){
//Add code to handle your event here.
var grid = igtbl_getGridById(gridName);
for(var i=0;i<grid.Rows.length;i++)
{
var uRow = grid.Rows.getRow(i);
uRow.Element.style.backgroundColor = 'White';
}
var uCurrentRow =igtbl_getRowById(rowId);
uCurrentRow.Element.style.backgroundColor='LightSkyBlue';
}
The following codes can be used to validated the input of the infragistics webgrid
<script language="javascript">
function IsGridValid()
{
var grid = igtbl_getGridById('UltraWebGrid1');
for(var i=0;i<grid.Rows.length;i++)
{
var uRow = grid.Rows.getRow (i);
var uCell = uRow.getCellFromKey("CategoryID");
alert(uCell.getValue());
debugger;
}
alert("In valid");
return false;
}
</script>
this.Button1.Attributes.Add("OnClick","return IsGridValid();");
Thursday, October 26, 2006
Serialize class to XML
If a class include an arraylist, the XMLElement attribute need to be added in the top of the arraylist.
ex: [XmlElement(typeof(ImportColumnDefinition))]
public ArrayList ColumnsList
{
get{ return this.columnsList;}
set{ this.columnsList = value;}
}
The following method will serialze the class to xml:
public string ToXML()
{
StringWriter Output = new StringWriter(new StringBuilder());
string Ret="";
try
{
XmlSerializer s = new XmlSerializer(this.GetType());
s.Serialize(Output,this);
// To cut down on the size of the xml being sent to the database, we'll strip
// out this extraneous xml.
Ret = Output.ToString();
}
catch (Exception) { throw; }
return Ret;
}
ex: [XmlElement(typeof(ImportColumnDefinition))]
public ArrayList ColumnsList
{
get{ return this.columnsList;}
set{ this.columnsList = value;}
}
The following method will serialze the class to xml:
public string ToXML()
{
StringWriter Output = new StringWriter(new StringBuilder());
string Ret="";
try
{
XmlSerializer s = new XmlSerializer(this.GetType());
s.Serialize(Output,this);
// To cut down on the size of the xml being sent to the database, we'll strip
// out this extraneous xml.
Ret = Output.ToString();
}
catch (Exception) { throw; }
return Ret;
}
Tuesday, October 03, 2006
How to bind ArrayList to Repeater
<form id="form1" runat="server">
<?xml:namespace prefix = asp /><asp:repeater id="Repeater1" runat="server" onitemdatabound="Repeater1_ItemDataBound">
<headertemplate>
<table border="1">
<tbody><tr>
<td>Source</td><td>Destination</td>
</tr>
</headertemplate>
<itemtemplate>
<tr>
<td>
<asp:label id="Source" text=<%# Container.DataItem %> runat="server" />
</td>
<td><asp:dropdownlist id="Dest" runat="server" autopostback="true"></td>
</tr>
</itemtemplate>
<footertemplate>
</tbody></table>
</footertemplate>
</asp:repeater></asp:dropdownlist></asp:label>
<asp:button id="Button_OK" onclick="Button_OK_Click" runat="server" text="OK" width="80px"></asp:button>
<asp:label id="Source" text=""><asp:dropdownlist id="Dest" runat="server" autopostback="true">
</form>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Repeater : System.Web.UI.Page
{
public ArrayList dropList;
protected void Page_Load(object sender, EventArgs e)
{
ArrayList alist = new ArrayList();
alist.Add("a1");
alist.Add("a2");
alist.Add("a3");
alist.Add("a4");
if (!IsPostBack)
{
this.Repeater1.DataSource = alist;
this.Repeater1.DataBind();
}
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
DropDownList list = (DropDownList)e.Item.FindControl("Dest");
if(list != null)
{
dropList = new ArrayList();
dropList.Add("d1");
dropList.Add("d2");
dropList.Add("d3");
dropList.Add("d4");
list.DataSource = dropList;
list.DataBind();
}
}
protected void Button_OK_Click(object sender, EventArgs e)
{
string selectedColumn = "";
string sourceColumn = "";
foreach (RepeaterItem item in this.Repeater1.Items)
{
Label lb = (Label)item.FindControl("Source");
sourceColumn += lb.Text;
DropDownList drop = (DropDownList)item.FindControl("Dest");
string selectedValue = drop.SelectedValue;
selectedColumn += selectedValue + ", ";
string text = item.ToString();
}
Response.Write(selectedColumn);
Response.Write("
" + sourceColumn);
}
}
Ref: http://www.codecomments.com/archive315-2005-3-433360.html
Ref: http://www.asp101.com/articles/lee/multiupdate/default.asp
Ref: http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/ctrlref/webctrl/Button/Button2.src
<?xml:namespace prefix = asp /><asp:repeater id="Repeater1" runat="server" onitemdatabound="Repeater1_ItemDataBound">
<headertemplate>
<table border="1">
<tbody><tr>
<td>Source</td><td>Destination</td>
</tr>
</headertemplate>
<itemtemplate>
<tr>
<td>
<asp:label id="Source" text=<%# Container.DataItem %> runat="server" />
</td>
<td><asp:dropdownlist id="Dest" runat="server" autopostback="true"></td>
</tr>
</itemtemplate>
<footertemplate>
</tbody></table>
</footertemplate>
</asp:repeater></asp:dropdownlist></asp:label>
<asp:button id="Button_OK" onclick="Button_OK_Click" runat="server" text="OK" width="80px"></asp:button>
<asp:label id="Source" text=""><asp:dropdownlist id="Dest" runat="server" autopostback="true">
</form>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Repeater : System.Web.UI.Page
{
public ArrayList dropList;
protected void Page_Load(object sender, EventArgs e)
{
ArrayList alist = new ArrayList();
alist.Add("a1");
alist.Add("a2");
alist.Add("a3");
alist.Add("a4");
if (!IsPostBack)
{
this.Repeater1.DataSource = alist;
this.Repeater1.DataBind();
}
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
DropDownList list = (DropDownList)e.Item.FindControl("Dest");
if(list != null)
{
dropList = new ArrayList();
dropList.Add("d1");
dropList.Add("d2");
dropList.Add("d3");
dropList.Add("d4");
list.DataSource = dropList;
list.DataBind();
}
}
protected void Button_OK_Click(object sender, EventArgs e)
{
string selectedColumn = "";
string sourceColumn = "";
foreach (RepeaterItem item in this.Repeater1.Items)
{
Label lb = (Label)item.FindControl("Source");
sourceColumn += lb.Text;
DropDownList drop = (DropDownList)item.FindControl("Dest");
string selectedValue = drop.SelectedValue;
selectedColumn += selectedValue + ", ";
string text = item.ToString();
}
Response.Write(selectedColumn);
Response.Write("
" + sourceColumn);
}
}
Ref: http://www.codecomments.com/archive315-2005-3-433360.html
Ref: http://www.asp101.com/articles/lee/multiupdate/default.asp
Ref: http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/ctrlref/webctrl/Button/Button2.src
Upload Excel to SQL through web application
SQL Data Types Mapping
ref: http://msdn2.microsoft.com/en-us/library/4e5xt97a.aspx
Set up a folder that both the web app and SQL server can get to.Do a simple file upload from the web appSet up a DTS package to periodically check the folder to do an import-or-Set up a DTS package that will do the import and call it from a StoredProc after the web app does the upload
ref: http://support.microsoft.com/?kbid=321686
SELECT * INTO XLImport5 FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\dev\test.xls', 'SELECT * FROM [sheet1$]')
use the ADO.NET loading the excel
ref: http://davidhayden.com/blog/dave/archive/2006/05/31/2975.aspx
How to read excel sheet schema information with .net
Dim i As Integer
Dim dtXlsSchema As DataTable
Dim myConn As New OleDbConnection
Dim XlsConn As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data " & _
"Source=C:\temp\myWorksheet.xls;" & _
"Extended Properties=Excel 8.0"
'
' Open an ADO connection to the Excel file.
'
myConn.ConnectionString = XlsConn
myConn.Open()
'
' Get a list of tables (worksheets) in the XLS file.
'
dtXlsSchema = myConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, _
New Object() {Nothing, Nothing, Nothing, "TABLE"})
For i = 0 To dtXlsSchema.Rows.Count - 1
Debug.WriteLine(dtXlsSchema.Rows(i).Item("Table_Name").ToString)
Next
'
' Get the schema for the specified table.
' Change "MyTableName" to the actual worksheet name.
'
dtXlsSchema = myConn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, _
New Object() {Nothing, Nothing, "MyTableName$", "TABLE"})
For i = 0 To dtXlsSchema.Columns.Count - 1
Debug.WriteLine(dtXlsSchema.Columns(i).ToString)
Next
'
' List the columns for the specified table.
'
dtXlsSchema = myConn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, _
New Object() {Nothing, Nothing, "MyTableName$", Nothing})
For i = 0 To dtXlsSchema.Rows.Count - 1
Debug.WriteLine(dtXlsSchema.Rows(i).Item("Column_Name").ToString)
Next
myConn.Close()
Ref: http://www.thescarms.com/dotnet/Schema.asp
Upload a File with asp.net 1.1
ref: http://support.microsoft.com/default.aspx?scid=kb;en-us;323245&Product=aspnet
ref: http://msdn2.microsoft.com/en-us/library/4e5xt97a.aspx
Set up a folder that both the web app and SQL server can get to.Do a simple file upload from the web appSet up a DTS package to periodically check the folder to do an import-or-Set up a DTS package that will do the import and call it from a StoredProc after the web app does the upload
ref: http://support.microsoft.com/?kbid=321686
SELECT * INTO XLImport5 FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\dev\test.xls', 'SELECT * FROM [sheet1$]')
use the ADO.NET loading the excel
ref: http://davidhayden.com/blog/dave/archive/2006/05/31/2975.aspx
How to read excel sheet schema information with .net
Dim i As Integer
Dim dtXlsSchema As DataTable
Dim myConn As New OleDbConnection
Dim XlsConn As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data " & _
"Source=C:\temp\myWorksheet.xls;" & _
"Extended Properties=Excel 8.0"
'
' Open an ADO connection to the Excel file.
'
myConn.ConnectionString = XlsConn
myConn.Open()
'
' Get a list of tables (worksheets) in the XLS file.
'
dtXlsSchema = myConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, _
New Object() {Nothing, Nothing, Nothing, "TABLE"})
For i = 0 To dtXlsSchema.Rows.Count - 1
Debug.WriteLine(dtXlsSchema.Rows(i).Item("Table_Name").ToString)
Next
'
' Get the schema for the specified table.
' Change "MyTableName" to the actual worksheet name.
'
dtXlsSchema = myConn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, _
New Object() {Nothing, Nothing, "MyTableName$", "TABLE"})
For i = 0 To dtXlsSchema.Columns.Count - 1
Debug.WriteLine(dtXlsSchema.Columns(i).ToString)
Next
'
' List the columns for the specified table.
'
dtXlsSchema = myConn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, _
New Object() {Nothing, Nothing, "MyTableName$", Nothing})
For i = 0 To dtXlsSchema.Rows.Count - 1
Debug.WriteLine(dtXlsSchema.Rows(i).Item("Column_Name").ToString)
Next
myConn.Close()
Ref: http://www.thescarms.com/dotnet/Schema.asp
Upload a File with asp.net 1.1
ref: http://support.microsoft.com/default.aspx?scid=kb;en-us;323245&Product=aspnet
Subscribe to:
Posts (Atom)