Friday, May 30, 2008

Table Clone in ASP.Net

'Assuming we have table in our dataset called 'ds'

Dim tempTable As DataTable
tempTable = ds.Tables(0).Clone

'Creating columns with datatypes
For k As Integer = 1 To 11
tempTable.Columns("col" & k).DataType = System.Type.GetType("System.Int32")
Next

'Importing Rows
For Each dr1 As DataRow In ds.Tables(1).Rows
tempTable.ImportRow(dr1)
Next

'Adding table to existing dataset.
tempTable.TableName = "NewTempTable"
ds.Tables.Add(tempTable)

Thats it.

Regards

Thursday, May 29, 2008

AlternatingItem Property in DataGrid

If you like to use AlternatingRowStyle property like Gridview has inside DataGrid, thats how you use it:

Protected Sub HG1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles HG1.ItemDataBound

If e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.BackColor = Drawing.Color.Silver
End If

End Sub

Tuesday, May 20, 2008

Access Gridview Checkbox in VB.net

For Each row As GridViewRow In GridView1.Rows
' Access the CheckBox
Dim cell As TableCell = row.Cells(7) '7 is Column index
Dim cb As CheckBox = (CType(cell.Controls(1), CheckBox))
If cb IsNot Nothing And cb.Checked Then
sHeader = sHeader & GridView1.DataKeys(row.RowIndex).Value
End If
Next

Monday, May 12, 2008

IIS Worker Process

An Internet Information Services (IIS) worker process is a windows process (w3wp.exe) which runs Web applications, and is responsible for handling requests sent to a Web Server for a specific application pool.