31.3.09

Previous Papers

http://previouspapers.blogspot.com/

22.3.09

tool Tip Vista skin

/* r.a.d.tooltip TELERIK skin */

/* r.a.d.tooltip resize element */
div.radtooltip_Telerik.ResizeElement
{
border: solid 1px #d3fd2c;
background: #f8fce0;
}

div.radtooltip_Telerik.LoadingSign
{
background: url(ToolTip/Loading.gif) no-repeat center;
width: 100%; height: 100%;
}

div.radtooltip_Telerik
{
position: absolute;
cursor: default;
}

div.radtooltip_Telerik.visiblecallout
{
/**/
}

div.radtooltip_Telerik.visiblecallout div.ToolTipCallout
{
display: block;
}


div.radtooltip_Telerik table.ToolTipWrapper
{
padding: 0; margin: 0;
border-collapse: collapse;
}

div.radtooltip_Telerik table.ToolTipWrapper td
{
padding: 0; margin: 0;
border-collapse: collapse;
text-align: left;
}

/* -------------------------- CORNER SETTINGS BEGIN ---------------------------------- */
div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipTopLeft,
div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipTopRight,
div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipBottomLeft,
div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipBottomRight
{
width: 3px; height: 3px; line-height: 0px;
font-size: 1px;
background-image: url(ToolTip/TooltipCorners.gif) ;
background-repeat: no-repeat;
}

div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipTopLeft
{
background-position: 0 0;
}

div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipTopRight
{
background-position: right 0;
}

div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipBottomLeft
{
background-position: 0 bottom;
}

div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipBottomRight
{
background-position: right bottom;
}

div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipTopCenter,
div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipBottomCenter
{
height: 3px; line-height: 0px;
font-size: 1px;
background: url(ToolTip/ToolTipTopParts.gif) ;
background-repeat: repeat-x;
}

div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipTopCenter
{
background-position: 0 0;
}

div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipBottomCenter
{
background-position: 0 bottom;
}

div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipLeftMiddle,
div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipRightMiddle
{
background-image: url(ToolTip/TooltipSideParts.gif) ;
background-repeat: repeat-y;
font-size: 1px;
width: 3px;
}

div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipLeftMiddle
{
background-position: 0 0;
}

div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipRightMiddle
{
background-position: right 0;
}
/* -------------------------- CORNER SETTINGS END ---------------------------------- */
div.radtooltip_Telerik table.ToolTipWrapper td.ToolTipContent
{
font: normal 11px Arial, Verdana, Sans-serif;
height: 100%;
background: #f3f3f3 url(ToolTip/ContentBgr.gif) repeat-x;
}

div.radtooltip_Telerik div.ToolTipTitlebar
{
color: black;
font: bold 11px Verdana, Arial, Sans-serif;
float:left;
line-height: 22px;
}

/* close button */
div.radtooltip_Telerik a.CloseButton,
div.radtooltip_Telerik a.CloseButton:hover
{
display: block; float: right;
width: 15px; line-height: 1px; height: 14px; font-size: 1px;
margin-top: 4px;
margin-right: 1px;
background: url(ToolTip/close.gif) no-repeat;
text-indent: -9999px;
outline: none;
}

/* --------------------------------------------- TOOLTIP CALLOUT SETTINGS BEGIN --------------------------------------------- */
div.radtooltip_Telerik div.ToolTipCallout
{
position: absolute; top: 0; left: 0;
height: 11px; width: 11px;
line-height: 1px; font-size: 1px;
background-image: url(ToolTip/Callouts.gif) ;
background-repeat: no-repeat;
}

/* position="Center" */
div.radtooltip_Telerik .Center
{
background: none !important;
}

/* position="BottomRight" */
.radtooltip_Telerik .TopLeft
{
margin-top: -9px; margin-left: 5px;
background-position: 0 -22px;
}

/* position="BottomCenter" */
.radtooltip_Telerik .TopCenter
{
left: 50% !important;
margin-top: -9px; margin-left: -5px;
background-position: 0 0 !important;
}

/* position="BottomLeft" */
.radtooltip_Telerik .TopRight
{
left: 100% !important;
margin-top: -9px; margin-left: -20px;
background-position: 0 -11px !important;
}

/* position="TopCenter" */
.radtooltip_Telerik .BottomCenter
{
top: 100% !important; left: 50% !important;
margin-left: -5px !important; margin-top: -2px !important; _margin-top: -1px !important;
width: 100% !important;
background-position: 0 -55px !important;
}

/* position="TopLeft" */
.radtooltip_Telerik .BottomRight
{
top: 100% !important; left: 100% !important;
margin-left: -20px !important; margin-top: -2px !important; _margin-top: -1px !important;
background-position: 0 -66px !important;
}

/* position="TopRight" */
.radtooltip_Telerik .BottomLeft
{
top: 100% !important;
margin-left: 5px !important; margin-top: -2px !important; _margin-top: -1px !important;
background-position: 0 -77px !important;
}

/* position="MiddleRight" */
.radtooltip_Telerik .MiddleLeft
{
top: 50% !important;
margin-left: -9px; margin-top: -5px;
background-position: 0 -33px !important;
}

/* position="MiddleLeft" */
.radtooltip_Telerik .MiddleRight
{
left: 100% !important; top: 50% !important;
margin-left: -2px; margin-top: -5px;
background-position: 0 -44px;
}
/* --------------------------------------------- TOOLTIP CALLOUT SETTINGS END --------------------------------------------- */

21.3.09

MySQL Installing

http://www.15seconds.com/issue/050210.htm

20.3.09

Vb.net

Import Excel TO Sequel database BY click on asp.net page button
using System;
using System.Data;
using System.Configuration;
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;
using System.Data.SqlClient;
using Microsoft.VisualBasic;
using System.IO;
using System.Net;
using System.Text;
using System.Data.OleDb;
using System.Data.Common;
using System.Diagnostics;



public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{


}


protected void Button1_Click(object sender, EventArgs e)
{
// Connection String to Excel Workbook
//string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Book1.xls;Extended Properties=""Excel 8.0; HDR=YES;""";
String strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=C:\\tblprod.xls;" + "Extended Properties=Excel 8.0;";
// Create Connection to Excel Workbook
//using (OleDbConnection = new OleDbConnection(excelConnectionString)) ;
OleDbConnection connection = new OleDbConnection(strConn);
OleDbCommand command = new OleDbCommand("Select * FROM [Data$]", connection);
connection.Open();
// Create DbDataReader to Data Worksheet
//using (SqlDataReader dr = command.ExecuteReader())
DbDataReader dr = command.ExecuteReader();


//// SQL Server Connection String
//string sqlConnectionString = "Data Source=.;Initial Catalog=Test;Integrated Security=True";
//string sqlConnectionString = "Data Source=.;Initial Catalog=exceldata;Integrated Security=True";
string sqlConnectionString = "server=system2;database=goelco;uid=sa";
// Bulk Copy to SQL Server
//using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString))
SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString);
bulkCopy.DestinationTableName = "tblprod";
bulkCopy.WriteToServer(dr);
dr.Close();
}
Posted by sahil31_mohali at 10:36 AM 0 comments
Crystal Report Problem
protected void Button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("sp_repairid", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.Add("@Repairid", SqlDbType.Int).Value = TextBox1.Text;
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds, "tbrepair1");
//int tes = ds.Tables[0].Rows.Count;
ReportDocument report = new ReportDocument();
report.FileName = Server.MapPath("crystalreport2.rpt");
report.SetDataSource(ds);
//report.PrintOptions.PrinterName=
//report.PrintToPrinter(1,false,0,0);
CrystalReportViewer1.ReportSource = report;
CrystalReportViewer1.DataBind();
cmd.Dispose();
}
Posted by sahil31_mohali at 10:36 AM 0 comments
Download File Code in vb.net
Private Sub DownloadFile(ByVal fname As String, ByVal forceDownload As Boolean)
Dim path As Path
Dim fullpath = IO.Path.GetFullPath(fname)
Dim name = IO.Path.GetFileName(fullpath)
Dim ext = IO.Path.GetExtension(fullpath)
Dim type As String = ""
If Not IsDBNull(ext) Then
ext = LCase(ext)
End If
Select Case ext
Case ".htm", ".html"
type = "text/HTML"
Case ".txt"
type = "text/plain"
Case ".doc", ".rtf"
type = "Application/msword"
Case ".csv", ".xls"
type = "Application/x-msexcel"
Case Else
type = "text/plain"
End Select
If (forceDownload) Then
Response.AppendHeader("content-disposition", _
"attachment; filename=" + name)
End If
If type <> "" Then
Response.ContentType = type
End If
Response.WriteFile(fullpath)
Response.End()
End Sub
Posted by sahil31_mohali at 10:35 AM 0 comments
Gridview with template field in vb.net...we can edit and update here
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.Page
Imports shopping.classConnection
Partial Class userdetail
Inherits System.Web.UI.Page
Dim cmd As New SqlCommand()
Dim con As New shopping.classConnection()
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack = False Then
userdetail()
End If
End Sub
Private Function userdetail()
Dim adpuserdetail As New SqlDataAdapter
Dim dsuserdetail As New Data.DataSet
cmd.CommandText = "select * from tblUserDetail order by userid"
cmd.Connection = con.createConnection(Session("site"))
adpuserdetail.SelectCommand = cmd
adpuserdetail.Fill(dsuserdetail)
grduserdetail.DataSource = dsuserdetail
grduserdetail.DataBind()
End Function
Protected Sub grduserdetail_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles grduserdetail.RowEditing
grduserdetail.EditIndex = e.NewEditIndex
userdetail()
End Sub
Protected Sub grduserdetail_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles grduserdetail.RowUpdating
Dim varuserid As Int32 = CType(grduserdetail.Rows(e.RowIndex).FindControl("userid"), Label).Text
Dim struserTitle As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("usertitle"), TextBox).Text
Dim strfirstName As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("firstname"), TextBox).Text
Dim strsurname As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("surname"), TextBox).Text
Dim straddress1 As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("address1"), TextBox).Text
Dim straddress2 As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("address2"), TextBox).Text
Dim straddress3 As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("address3"), TextBox).Text
Dim strcity As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("city"), TextBox).Text
Dim strpostCode As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("postCode"), TextBox).Text
Dim strcountry As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("country"), TextBox).Text
Dim strphone1 As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("phone1"), TextBox).Text
Dim strphone2 As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("phone2"), TextBox).Text
Dim strusername As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("username"), TextBox).Text
Dim strpassword As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("password"), TextBox).Text
Dim strstatus As Char = CType(grduserdetail.Rows(e.RowIndex).FindControl("status"), TextBox).Text
Dim strdate As Date = CType(grduserdetail.Rows(e.RowIndex).FindControl("date1"), TextBox).Text
Dim strsaveas As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("saveas"), TextBox).Text
Dim varprefrence As Int32 = CType(grduserdetail.Rows(e.RowIndex).FindControl("prefrence"), TextBox).Text
'Dim boolActive As Boolean = CType(grduserdetail.Rows(e.RowIndex).FindControl("check"), CheckBox).Checked
'Dim varactive As Int32
'If boolActive = True Then
' varactive = 1
'ElseIf boolActive = False Then
' varactive = 0
'End If
cmd.CommandText = "update tblUserDetail set userTitle='" & struserTitle & "', firstName ='" & strfirstName & "', surname ='" & strsurname & "', address1='" & straddress1 & "', address2='" & straddress2 & "', address3 ='" & straddress3 & "', city='" & strcity & "', postCode ='" & strpostCode & "',country='" & strcountry & "', phone1 ='" & strphone1 & "',phone2 ='" & strphone2 & "',username ='" & strusername & "',password='" & strpassword & "', status ='" & strstatus & "', date=" & strdate & ", saveas ='" & strsaveas & "',prefrence =" & varprefrence & " where userid =" & varuserid
cmd.Connection = con.createConnection(Session("site"))
cmd.ExecuteNonQuery()
grduserdetail.EditIndex = -1
userdetail()
End Sub
Protected Sub grduserdetail_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles grduserdetail.RowCancelingEdit
grduserdetail.EditIndex = -1
userdetail()
End Sub
End Class
Posted by sahil31_mohali at 10:35 AM 0 comments
ADMIN LOGIN page in VB.net
Purpose: Admin login into admin section
' Process: 1. Checking of username and paswword

Imports System.Data.SqlClient
Imports shopping.classConnection
Partial Class _Default
Inherits System.Web.UI.Page
Dim con As New shopping.classConnection
Dim cmd As New SqlCommand
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack = False Then
cmd.Connection = con.createConnection(1)
End If
txtName.Focus()
'txtName.Text = "admin"
'txtPassword.Text = "admin"
End Sub
' Process 1
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If Page.IsValid Then


Dim strLogName As String
Dim strPassword As String
strLogName = txtName.Text
strLogName = Replace(strLogName, "'", "''")
strPassword = txtPassword.Text
strPassword = Replace(strPassword, "'", "''")
If strLogName <> "" And strPassword <> "" Then
Dim cmd As New SqlCommand
cmd.CommandText = "select LogName,Passwd,rights,site from tblAdmin where LogName='" & strLogName & "' and Passwd='" & strPassword & "'"
cmd.Connection = con.createConnection(1)
Dim drLogin As SqlDataReader = cmd.ExecuteReader
If drLogin.Read Then
Session("UserName") = drLogin("LogName")
Session("Rights") = drLogin("rights")
Session("Site") = drLogin("site")
drLogin.Close()
cmd.Dispose()
lblResult.Text = "LogIn Succeed"
Response.Redirect("adminFrames.aspx")
Else
drLogin.Close()
cmd.Dispose()
lblResult.Text = "Incorrect Username or Password"
txtName.Text = ""
txtPassword.Text = ""
End If
End If
End If
End Sub
End Class
Posted by sahil31_mohali at 10:34 AM 0 comments
Back UP of Database on System in vb.net
Imports System.Data.SqlClient
Imports shopping.classConnection
Partial Class bkup

Inherits System.Web.UI.Page
Dim objConnection As New shopping.classConnection()
Dim cmd As New SqlCommand()
Dim adp As New SqlDataAdapter() '("select * from tblCat", objConnection.con)
Dim ds As New Data.DataSet()
Dim dtreader As SqlDataReader
Dim strSql As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Put user code to initialize the page here
If Session("username") = "" Then
Session.Abandon()
Response.Redirect("error.aspx")
End If

End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim cmd As New SqlCommand
cmd.CommandText = "bkup"
cmd.Connection = objConnection.createConnection(Session("site"))
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.ExecuteNonQuery()
cmd.Dispose()
lblresult.Text = "Backup of Database is being taken sucessfully"
Catch ex As Exception
lblresult.Text = "Sorry there is sum problem in taking database backup try again"
End Try
End Sub
'Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload.Click
' Dim mystreamwriter As System.IO.TextWriter
' mystreamwriter = Response.Output
' mystreamwriter.WriteLine("This is a test download text file")
' mystreamwriter.Write(Date.Now.ToLongDateString() & " " & Date.Now.ToLongTimeString())
' mystreamwriter.Close()
' Response.AddHeader("content-disposition", "attachmentfilename=download.txt")
'End Sub
End Class




ALTER PROCEDURE bkup
as
DECLARE @name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20) -- used for file name
SET @path = 'C:\Backup\'
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)
DECLARE db_cursor CURSOR FOR
SELECT name FROM master.dbo.sysdatabases WHERE name ='goelco'
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN
SET @fileName = @path + @name + '_' + @fileDate + '.BAK'
BACKUP DATABASE @name TO DISK = @fileName
FETCH NEXT FROM db_cursor INTO @name
END
CLOSE db_cursor
DEALLOCATE db_cursor
Posted by sahil31_mohali at 10:33 AM 0 comments
Make Log ERROR FILE in vb.net
Dim FILENAME As String = Server.MapPath("style\style.css")
Dim srw As StreamWriter = New StreamWriter(FILENAME)
srw.WriteLine(".subCategories{")
srw.WriteLine("font-family:" & var152 & ";")
srw.WriteLine("font-size:" & var1 & "px;")
srw.WriteLine("border-bottom-width:" & var3 & "px;")
srw.WriteLine("border-bottom:" & var4 & ";")
srw.WriteLine("border-bottom-color:#" & var5 & ";")
srw.WriteLine("}")
Posted by sahil31_mohali at 10:32 AM 0 comments


Sunday, February 1, 2009
To Check Null Condition in Datareader
If dr.Read Then
If IsDBNull(dr(0)) = True Then
orderno = 1
Else
orderno = dr(0) + 1
End If
Session("orderno") = orderno
End If
Posted by sahil31_mohali at 10:31 AM 0 comments
Tempory TABLE in vb.net with Gridview
Private Function temptable()
Dim dtcart As New DataTable
dtcart.Columns.Add("PID", Type.GetType("System.Int32"))
dtcart.Columns.Add("quantity", Type.GetType("System.Int32"))
dtcart.Columns.Add("amount", Type.GetType("System.Double"))
dtcart.Columns.Add("price", Type.GetType("System.Double"))
dtcart.Columns.Add("prdname", Type.GetType("System.String"))
dtcart.PrimaryKey = New DataColumn() {dtcart.Columns("pid")}
Dim lblamount As Double
Dim pid As Int32
Dim qty As Int32
Dim price As Double
Dim prdname As String
Dim i As Int32
For i = 0 To GridView1.Rows.Count - 1
'lblamount = CType(GridView1.Rows.Item(i).FindControl("Label7"), Label).Text
lblamount = CType(GridView1.Rows.Item(i).FindControl("Label6"), Label).Text * CType(GridView1.Rows.Item(i).FindControl("qty"), TextBox).Text
pid = CType(GridView1.Rows.Item(i).FindControl("Label2"), Label).Text
qty = CType(GridView1.Rows.Item(i).FindControl("qty"), TextBox).Text
price = CType(GridView1.Rows.Item(i).FindControl("Label6"), Label).Text
prdname = CType(GridView1.Rows.Item(i).FindControl("Label1"), Label).Text
Dim row As DataRow = dtcart.NewRow
row("PID") = pid
row("quantity") = qty
row("amount") = lblamount
row("price") = price
row("prdname") = prdname
dtcart.Rows.Add(row)
Next
Session("dtcart") = dtcart
End Function




If Session("abc") Is Nothing Then
Dim dtCart As New DataTable()
dtCart.Columns.Add("PID", Type.GetType("System.Int32"))
dtCart.Columns.Add("quantity", Type.GetType("System.Int32"))
dtCart.PrimaryKey = New DataColumn() {dtCart.Columns("pid")}
Session("abc") = dtCart
End If

Private Function grdbind()
Dim dt As New DataTable
dt = Session("abc")
GridView1.DataSource = dt
GridView1.DataBind()



End Function
Posted by sahil31_mohali at 10:30 AM 0 comments
Pick UP GRIDview values on BUTTON CLICK in VB.net
Protected Sub btnactive_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Try
Dim strPid As String
Dim varCount As Int32 = 0
While varCount < grdexistingproduct.Rows.Count
Dim grdRow As GridViewRow = grdexistingproduct.Rows(varCount)
Dim boolIschecked As Boolean = CType(grdRow.FindControl("chkSelect"), CheckBox).Checked
If boolIschecked Then
strPid = grdexistingproduct.Rows(varCount).Cells(3).Text
cmd.CommandText = "update tblprod set active='1' where pid='" & strPid & "'"
cmd.Connection = con.createConnection(Session("site"))
cmd.ExecuteNonQuery()
cmd.Dispose()
Else
strPid = grdexistingproduct.Rows(varCount).Cells(3).Text
cmd.CommandText = "update tblprod set active='0' where pid='" & strPid & "'"
cmd.Connection = con.createConnection(Session("site"))
cmd.ExecuteNonQuery()
cmd.Dispose()
End If
varCount = varCount + 1
End While
'Bind_Productsdeactivate()
'lblRes.Text = "Modifications are being saved"
Catch ex As Exception
'lblRes.Text = ex.Message
End Try
End Sub
Posted by sahil31_mohali at 10:30 AM 0 comments
Applying Loop to datareader in vb.net with CHECHBOX
cmd.CommandText = "select tradeno from tblmultipletrade where pid = " & prodno
cmd.Connection = con.createConnection(Session("site"))
Dim dcheck As SqlDataReader
dcheck = cmd.ExecuteReader()
If dcheck.HasRows Then
While dcheck.Read()
Dim varCountTrade As Int32 = 0
For varCountTrade = 0 To dlstTrade.Items.Count - 1
Dim varItem As DataListItem = dlstTrade.Items(varCountTrade)
Dim varTradeno As Int32 = CType(varItem.FindControl("catid"), Label).Text
Dim intColIndex As Int32

For intColIndex = 0 To dcheck.FieldCount - 1

If varTradeno = dcheck.GetValue(intColIndex) Then
CType(varItem.FindControl("check"), CheckBox).Checked = True
End If
Next
Next
End While
End If
dcheck.Close()
cmd.Dispose()
Posted by sahil31_mohali at 10:29 AM 0 comments
ROOT TREE CODING IN VB>NET
Private Sub PopulateRootLevel() ' Tree-------------START
Dim objCommand As New SqlCommand("select catid,catname,(select count(*) FROM tblcat WHERE pcatid=sc.catid) childnodecount FROM tblcat sc where pcatid='-1' order by serialno,catid")
objCommand.Connection = con.createConnection(Session("site"))
Dim da As New SqlDataAdapter(objCommand)
Dim dt As New Data.DataTable()
da.Fill(dt)
PopulateNodes(dt, treeCategory.Nodes)
End Sub
Private Sub PopulateNodes(ByVal dt As Data.DataTable, ByVal nodes As TreeNodeCollection)
For Each dr As Data.DataRow In dt.Rows
Dim tn As New TreeNode()
tn.Text = dr("catname").ToString()
tn.Value = dr("catid").ToString()
nodes.Add(tn)
'If node has child nodes, then enable on-demand populating
tn.PopulateOnDemand = (CInt(dr("childnodecount")) > 0)
Next
End Sub
Private Sub PopulateSubLevel(ByVal parentid As Integer, ByVal parentNode As TreeNode)
Dim objCommand As New SqlCommand("select catid,catname,(select count(*) FROM tblcat WHERE pcatid=sc.catid) childnodecount FROM tblcat sc where pcatid=@pcatid order by serialno,catid")
objCommand.Connection = con.createConnection(Session("site"))
objCommand.Parameters.Add("@pcatid", Data.SqlDbType.Int).Value = parentid
Dim da As New SqlDataAdapter(objCommand)
Dim dt As New Data.DataTable()
da.Fill(dt)
PopulateNodes(dt, parentNode.ChildNodes)
End Sub
Protected Sub treeCategory_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles treeCategory.SelectedNodeChanged
lblSelprod.Text = treeCategory.SelectedNode.Text
lblselcataddpro.Text = treeCategory.SelectedNode.Text
Category_ExistingProducts_Bind()
ShowPanel(1, 1, 0, 0, 0)
lbl_selectedcategoryid.Visible = True
lbl_valueselectedcategory.Visible = True
lbl_valueselectedcategory.Text = treeCategory.SelectedNode.Value
End Sub


Protected Sub TreeView1_TreeNodePopulate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles treeCategory.TreeNodePopulate
PopulateSubLevel(CInt(e.Node.Value), e.Node)
End Sub
Posted by sahil31_mohali at 10:28 AM 0 comments
GRIdview Updating Write Query With conditions VB.ne
Protected Sub grdCategory_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs)
Try
Dim strCatid As String
Dim strCatprefix As String
Dim strCatname As String
Dim strCatdesc As String
Dim strSql As String
Dim boolGrouped As Boolean


strCatid = CType(grdCategory.Rows(e.RowIndex).FindControl("txtCategoryId"), TextBox).Text
strCatprefix = CType(grdCategory.Rows(e.RowIndex).FindControl("txtcategoryeditprefix"), TextBox).Text
strCatname = CType(grdCategory.Rows(e.RowIndex).FindControl("txtCategoryName"), TextBox).Text
strCatdesc = CType(grdCategory.Rows(e.RowIndex).FindControl("txtcategorydesc"), TextBox).Text
boolGrouped = CType(grdCategory.Rows(e.RowIndex).FindControl("chkGrdcategorygroupedit"), CheckBox).Checked
Dim varGroup As Int32
If boolGrouped Then
cmd.CommandText = "select b.catid,a.catid from tblcat a,tblcat b where a.pcatid=b.catid and b.catid=" & strCatid
cmd.Connection = con.createConnection(Session("site"))
Dim drCategory As SqlDataReader = cmd.ExecuteReader
If drCategory.HasRows = True Then
varGroup = 1
'lblCheck.Text = ""
Else
varGroup = 0
'lblCheck.Text = "The Category Have No Sub-Categories"
End If
drCategory.Close()
cmd.Dispose()
Else
varGroup = 0
End If
strSql = "update tblcat set grouped=" & varGroup & ","
If strCatprefix <> "" Then
strSql += " catprefix='" & strCatprefix & "'"
End If
If strCatname <> "" Then
strSql += ",catname='" & strCatname & "'"
End If
If strCatdesc <> "" Then
strSql += ",catdesc='" & strCatdesc & "'"
End If
strSql += " where catid='" & strCatid & "'"
cmd.CommandText = strSql
cmd.Connection = con.createConnection(Session("site"))
cmd.ExecuteNonQuery()
lblResult.Text = "Updated"
cmd.Dispose()
' grdCategory.EditItemIndex = -1
grdCategory.EditIndex = -1
Bind_Categories_DataGrid()
Catch ex As Exception
lblResult.Text = ex.Message
End Try
End Sub

Protected Sub grdCategory_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs)
grdCategory.EditIndex = -1
Bind_Categories_DataGrid()
End Sub
Posted by sahil31_mohali at 10:27 AM 0 comments
Csv Show into Gridview Vb.net Link
http://msconline.maconstate.edu/tutorials/ASPNET2/ASPNET03/aspnet03-06.aspx

Imports System.Data.OleDb
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim DBConnection = New OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("./Databases") & ";" & _
"Extended Properties=""text;HDR=Yes;FMT=Delimited""")
DBConnection.Open()

Dim SQLString As String = "SELECT * FROM products.csv"
Dim DBCommand = New OleDbCommand(SQLString, DBConnection)
Dim DBReader As OleDbDataReader = DBCommand.ExecuteReader()

TextOut.DataSource = DBReader
TextOut.DataBind()

DBReader.Close()
DBConnection.Close()
End Sub


End Class
Posted by sahil31_mohali at 10:25 AM 0 comments



Sunday, February 1, 2009
DatagridView binding with Coding in vb.net
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim pid As Integer = Convert.ToInt32(txtProductId.Text)
Dim Qty As Integer
If txtProductQuantity.Text = "" Then
Qty = 1
Else
Qty = Convert.ToInt32(txtProductQuantity.Text)
End If


cmd.CommandText = "select * from tblprod where pid=" & pid
cmd.Connection = con
Dim datareader As SqlDataReader = cmd.ExecuteReader
If datareader.HasRows = True Then
datareader.Read()
datareader.Close()


cmd.CommandText = "insert into tblWindow values(" & pid & "," & Qty & ")"
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()




cmd.CommandText = "select Pid,PrdName,Price from tblProd where Pid=" & pid
Dim ds As New Data.DataSet
Dim adp As New SqlDataAdapter
adp.SelectCommand = cmd
adp.Fill(ds, "table")
DataGrid_ProductDetail.DataSource = ds
'datagridview1.DataMember = "tablename"
'DataGrid_ProductDetail.DataBindings()
DataGrid_ProductDetail.DataMember = "table"
lblCheckPrd.Visible = False
Else
lblCheckPrd.Visible = True
lblCheckPrd.Text = "Invalid Pid"
cmd.Dispose()
datareader.Close()
End If

cmd.Dispose()
datareader.Close()
End Sub
Posted by sahil31_mohali at 10:24 AM 0 comments
java start and download
http://www.netbeans.org/kb/60/java/quickstart.html
Posted by sahil31_mohali at 10:19 AM 0 comments
Link button in First Column of Gridview in C#
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
Int32 pdetcod;
pdetcod = Convert.ToInt32(GridView1.SelectedDataKey.Value);
Session["prjcode2"] = pdetcod;
Response.Redirect("frmempprjdet.aspx");
}
//comment
Right click on Gridview Properties and give DataKeyName="id"
Posted by sahil31_mohali at 10:17 AM 0 comments
oops concept
1. Introduction
2. Background
3. Prerequisites
4. The Main Content
4.1. What is Software Architecture?
4.2. Why Architecture is important?
4.3. What is OOP?
4.4. What is an Object?
4.5. What is a Class?
4.6. How to identify and design a Class?
4.7. What is Encapsulation (or information hiding)?
4.8. What is Association?
4.9. What is the difference between Association, Aggregation and Composition?
4.10. What is Abstraction and Generalization?
4.11. What is an Abstract class?
4.12. What is an Interface?
4.13. What is the difference between a Class and an Interface?
4.14. What is the difference between an Interface and an Abstract class?
4.15. What is Implicit and Explicit Interface Implementations?
4.16. What is Inheritance?
4.17. What is Polymorphism?
4.18. What is Method Overloading?
4.19. What is Operator overloading?
4.20. What is Method Overriding?
4.21. What is a Use case?
4.22. What is a Class Diagram?
4.23. What is a Package Diagram?
4.24. What is a Sequence Diagram?
4.25. What is two-tier architecture?
4.26. What is three-tier architecture?
4.27. What is MVC architecture?
4.28. What is SOA?
4.29. What is the Data Access Layer?
4.30. What is the Business Logic Layer?
4.31. What is Gang of Four (GoF) Design Patterns?
5. What is the Conclusion?
6. What I Referred?
7. History
1. Introduction
I have noticed an increase in the number of articles published in the Architect category in code-project during the last few months. The number of readers for most of these articles is also high, though the ratings for the articles are not. This indicates that readers are interested in reading articles on Architecture, but the quality does not match their expectations. This article is a constructive attempt to group/ define/ explain all introductory concepts of software architecture for well seasoned developers who are looking to take their next step as system architects.
One day I read an article that said that the richest 2 percent own half the world's wealth. It also said that the richest 1 percent of adults owned 40 percent of global assets in the year 2000. And further, that the richest 10 percent of adults accounted for 85 percent of the world's total wealth. So there is an unbalanced distribution of wealth in the physical world. Have you ever thought of an unbalanced distribution of knowledge in the software world? According to my view point, the massive expansion of the software industry is forcing developers to use already implemented libraries, services and frameworks to develop software within ever shorter periods of time. The new developers are trained to use (I would say more often) already developed software components, to complete the development quicker. They just plug in an existing library and some how manage to achieve the requirements. But the sad part of the story is, that they never get a training to define, design the architecture for, and implement such components. As the number of years pass by, these developers become leads and also software architects. Their titles change, but the old legacy of not understanding, of not having any architectural experience continues, creating a vacuum of good architects. The bottom line is that only a small percentage of developers know how to design a truly object oriented system. The solution to this problem is getting harder every day as the aggressive nature of the software industry does not support an easy adjustment to existing processes, and also the related online teaching materials are either complex or less practical or sometimes even wrong. The most of them use impractical, irrelevant examples of shapes, animals and many other physical world entities to teach concepts of software architecture. There are only very few good business-oriented design references. Unfortunately, I myself am no exception and am a result of this very same system. I got the same education that all of you did, and also referred to the same resource set you all read.
Coming back to the initial point, I noticed that there is a knowledge gap, increasing every day, between the architects who know how to architect a system properly and the others who do not know. The ones, who know, know it right. But the ones, who do not know, know nothing. Just like the world’s wealth distribution, it is an unbalanced distribution of knowledge.
2. Background
This article began after reading and hearing the questions new developers have, on basics of software architecture. There are some good articles out there, but still developers struggle to understand the basic concepts, and more importantly, the way to apply them correctly.
As I see it, newcomers will always struggle to understand a precise definition of a new concept, because it is always a new and hence unfamiliar idea. The one, who has experience, understands the meaning, but the one who doesn’t, struggles to understand the very same definition. It is like that. Employers want experienced employees. So they say, you need to have experience to get a job. But how the hell is one supposed to have that experience if no one is willing to give him a job? As in the general case, the start with software architecture is no exception. It will be difficult. When you start to design your very first system, you will try to apply everything you know or learned from everywhere. You will feel that an interface needs to be defined for every class, like I did once. You will find it harder to understand when and when not to do something. Just prepare to go through a painful process. Others will criticize you, may laugh at you and say that the way you have designed it is wrong. Listen to them, and learn continuously. In this process you will also have to read and think a lot. I hope that this article will give you the right start for that long journey.
“The knowledge of the actions of great men, acquired by long experience in contemporary affairs, and a continual study of antiquity” – I read this phrase when I was reading the book named “The Art of War”, seems applicable here, isn’t it?
3. Prerequisites
This article is an effort to provide an accurate information pool for new developers on the basics of software architecture, focusing on Object Oriented Programming (OOP). If you are a developer, who has a minimum of three or more years of continuous development experience and has that hunger to learn more, to step-in to the next level to become a software architect, this article is for you.
4. The Main Content
4.1. What is Software Architecture?
Software Architecture is defined to be the rules, heuristics and patterns governing:
Partitioning the problem and the system to be built into discrete pieces
Techniques used to create interfaces between these pieces
Techniques used to manage overall structure and flow
Techniques used to interface the system to its environment
Appropriate use of development and delivery approaches, techniques and tools.
4.2. Why Architecture is important?

The primary goal of software architecture is to define the non-functional requirements of a system and define the environment. The detailed design is followed by a definition of how to deliver the functional behavior within the architectural rules. Architecture is important because it:
Controls complexity
Enforces best practices
Gives consistency and uniformity
Increases predictability
Enables re-use.
4.3. What is OOP?
OOP is a design philosophy. It stands for Object Oriented Programming. Object-Oriented Programming (OOP) uses a different set of programming languages than old procedural programming languages (C, Pascal, etc.). Everything in OOP is grouped as self sustainable "objects". Hence, you gain re-usability by means of four main object-oriented programming concepts.
In order to clearly understand the object orientation, let’s take your “hand” as an example. The “hand” is a class. Your body has two objects of type hand, named left hand and right hand. Their main functions are controlled/ managed by a set of electrical signals sent through your shoulders (through an interface). So the shoulder is an interface which your body uses to interact with your hands. The hand is a well architected class. The hand is being re-used to create the left hand and the right hand by slightly changing the properties of it.
4.4. What is an Object?
An object can be considered a "thing" that can perform a set of activities. The set of activities that the object performs defines the object's behavior. For example, the hand can grip something or a Student (object) can give the name or address.
In pure OOP terms an object is an instance of a class.
4.5. What is a Class?

A class is simply a representation of a type of object. It is the blueprint/ plan/ template that describe the details of an object. A class is the blueprint from which the individual objects are created. Class is composed of three things: a name, attributes, and operations.
public class Student
{
}
According to the sample given below we can say that the student object, named objectStudent, has created out of the Student class.
Student objectStudent = new Student();
In real world, you'll often find many individual objects all of the same kind. As an example, there may be thousands of other bicycles in existence, all of the same make and model. Each bicycle has built from the same blueprint. In object-oriented terms, we say that the bicycle is an instance of the class of objects known as bicycles.
In the software world, though you may not have realized it, you have already used classes. For example, the TextBox control, you always used, is made out of the TextBox class, which defines its appearance and capabilities. Each time you drag a TextBox control, you are actually creating a new instance of the TextBox class.
4.6. How to identify and design a Class?
This is an art; each designer uses different techniques to identify classes. However according to Object Oriented Design Principles, there are five principles that you must follow when design a class,
SRP - The Single Responsibility Principle

A class should have one, and only one, reason to change.
OCP - The Open Closed Principle

You should be able to extend a classes behavior, without modifying it.
LSP - The Liskov Substitution Principle

Derived classes must be substitutable for their base classes.
DIP - The Dependency Inversion Principle

Depend on abstractions, not on concretions.
ISP - The Interface Segregation Principle

Make fine grained interfaces that are client specific.
For more information on design principles, please refer to Object Mentor.
Additionally to identify a class correctly, you need to identify the full list of leaf level functions/ operations of the system (granular level use cases of the system). Then you can proceed to group each function to form classes (classes will group same types of functions/ operations). However a well defined class must be a meaningful grouping of a set of functions and should support the re-usability while increasing expandability/ maintainability of the overall system. In software world the concept of dividing and conquering is always recommended, if you start analyzing a full system at the start, you will find it harder to manage. So the better approach is to identify the module of the system first and then dig deep in to each module separately to seek out classes.
A software system may consist of many classes. But in any case, when you have many, it needs to be managed. Think of a big organization, with its work force exceeding several thousand employees (let’s take one employee as a one class). In order to manage such a work force, you need to have proper management policies in place. Same technique can be applies to manage classes of your software system as well. In order to manage the classes of a software system, and to reduce the complexity, the system designers use several techniques, which can be grouped under four main concepts named Encapsulation, Abstraction, Inheritance, and Polymorphism. These concepts are the four main gods of OOP world and in software term, they are called four main Object Oriented Programming (OOP) Concepts.
4.7. What is Encapsulation (or information hiding)?
The encapsulation is the inclusion within a program object of all the resources need for the object to function - basically, the methods and the data. In OOP the encapsulation is mainly achieved by creating classes, the classes expose public methods and properties. The class is kind of a container or capsule or a cell, which encapsulate the set of methods, attribute and properties to provide its indented functionalities to other classes. In that sense, encapsulation also allows a class to change its internal implementation without hurting the overall functioning of the system. That idea of encapsulation is to hide how a class does it but to allow requesting what to do.

In order to modularize/ define the functionality of a one class, that class can uses functions/ properties exposed by another class in many different ways. According to Object Oriented Programming there are several techniques, classes can use to link with each other and they are named association, aggregation, and composition.
There are several other ways that an encapsulation can be used, as an example we can take the usage of an interface. The interface can be used to hide the information of an implemented class.
IStudent myStudent = new LocalStudent();
IStudent myStudent = new ForeignStudent();
According to the sample above (let’s assume that LocalStudent and ForeignStudent are implemented by the IStudent interface) we can see how LocalStudent and ForeignStudent are hiding their, localize implementing information through the IStudent interface.
4.8. What is Association?
Association is a (*a*) relationship between two classes. It allows one object instance to cause another to perform an action on its behalf. Association is the more general term that define the relationship between two classes, where as the aggregation and composition are relatively special.
public class StudentRegistrar
{
public StudentRegistrar ();
{
new RecordManager().Initialize();
}
}
In this case we can say that there is an association between StudentRegistrar and RecordManager or there is a directional association from StudentRegistrar to RecordManager or StudentRegistrar use a (*Use*) RecordManager. Since a direction is explicitly specified, in this case the controller class is the StudentRegistrar.

To some beginners, association is a confusing concept. The troubles created not only by the association alone, but with two other OOP concepts, that is association, aggregation and composition. Every one understands association, before aggregation and composition are described. The aggregation or composition cannot be separately understood. If you understand the aggregation alone it will crack the definition given for association, and if you try to understand the composition alone it will always threaten the definition given for aggregation, all three concepts are closely related, hence must study together, by comparing one definition to another. Let’s explore all three and see whether we can understand the differences between these useful concepts.
4.9. What is the difference between Association, Aggregation and Composition?
Association is a (*a*) relationship between two classes, where one class use another. But aggregation describes a special type of an association. Aggregation is the (*the*) relationship between two classes. When object of one class has an (*has*) object of another, if second is a part of first (containment relationship) then we called that there is an aggregation between two classes. Unlike association, aggregation always insists a direction.
public class University
{
private Chancellor universityChancellor = new Chancellor();
}

In this case I can say that University aggregate Chancellor or University has an (*has-a*) Chancellor. But even without a Chancellor a University can exists. But a University cannot exist without Faculties, the life time of a University attached with the life time of its Faculty (or Faculties). If Faculties are disposed the University will not exist or wise versa. In that case we called that University is composed of Faculties. So that composition can be recognized as a special type of an aggregation.

Same way, as another example, you can say that, there is a composite relationship in-between a KeyValuePairCollection and a KeyValuePair. The two mutually depend on each other.
In summary, we can say that aggregation is a special kind of an association and composition is a special kind of an aggregation. (Association->Aggregation->Composition)

4.10. What is Abstraction and Generalization?
Abstraction is an emphasis on the idea, qualities and properties rather than the particulars (a suppression of detail). The importance of abstraction is derived from its ability to hide irrelevant details and from the use of names to reference objects. Abstraction is essential in the construction of programs. It places the emphasis on what an object is or does rather than how it is represented or how it works. Thus, it is the primary means of managing complexity in large programs.
While abstraction reduces complexity by hiding irrelevant detail, generalization reduces complexity by replacing multiple entities which perform similar functions with a single construct. Generalization is the broadening of application to encompass a larger domain of objects of the same or different type. Programming languages provide generalization through variables, parameterization, generics and polymorphism. It places the emphasis on the similarities between objects. Thus, it helps to manage complexity by collecting individuals into groups and providing a representative which can be used to specify any individual of the group.
Abstraction and generalization are often used together. Abstracts are generalized through parameterization to provide greater utility. In parameterization, one or more parts of an entity are replaced with a name which is new to the entity. The name is used as a parameter. When the parameterized abstract is invoked, it is invoked with a binding of the parameter to an argument.
4.11. What is an Abstract class?
Abstract classes, which declared with the abstract keyword, cannot be instantiated. It can only be used as a super-class for other classes that extend the abstract class. Abstract class is the concept and implementation gets completed when it is being realized by a subclass. In addition to this a class can inherit only from one abstract class (but a class may implement many interfaces) and must override all its abstract methods/ properties and may override virtual methods/ properties.
Abstract classes are ideal when implementing frameworks. As an example, let’s study the abstract class named LoggerBase below. Please carefully read the comments as it will help you to understand the reasoning behind this code.
Collapse
public abstract class LoggerBase
{
///
/// field is private, so it intend to use inside the class only
///

private log4net.ILog logger = null;

///
/// protected, so it only visible for inherited class
///

protected LoggerBase()
{
// The private object is created inside the constructor
logger = log4net.LogManager.GetLogger(this.LogPrefix);
// The additional initialization is done immediately after
log4net.Config.DOMConfigurator.Configure();
}

///
/// When you define the property as abstract,
/// it forces the inherited class to override the LogPrefix
/// So, with the help of this technique the log can be made,
/// inside the abstract
class itself, irrespective of it origin.
/// If you study carefully you will find a reason for not to have “set” method here.
///

protected abstract System.Type LogPrefix
{
get;
}

///
/// Simple log method,
/// which is only visible for inherited classes
///

///
protected void LogError(string
message)
{
if (this.logger.IsErrorEnabled)
{
this.logger.Error(message);
}
}

///
/// Public properties which exposes to inherited class
/// and all other classes that have access to inherited class
///

public bool IsThisLogError
{
get
{
return this.logger.IsErrorEnabled;
}
}
}
The idea of having this class as an abstract is to define a framework for exception logging. This class will allow all subclass to gain access to a common exception logging module and will facilitate to easily replace the logging library. By the time you define the LoggerBase, you wouldn’t have an idea about other modules of the system. But you do have a concept in mind and that is, if a class is going to log an exception, they have to inherit the LoggerBase. In other word the LoggerBase provide a framework for exception logging.
Let’s try to understand each line of the above code.
Like any other class, an abstract class can contain fields, hence I used a private field named logger declare the ILog interface of the famous log4net library. This will allow the Loggerbase class to control, what to use, for logging, hence, will allow changing the source logger library easily.
The access modifier of the constructor of the LoggerBase is protected. The public constructor has no use when the class is of type abstract. The abstract classes are not allowed to instantiate the class. So I went for the protected constructor.
The abstract property named LogPrefix is an important one. It enforces and guarantees to have a value for LogPrefix (LogPrefix uses to obtain the detail of the source class, which the exception has occurred) for every subclass, before they invoke a method to log an error.
The method named LogError is protected, hence exposed to all subclasses. You are not allowed or rather you cannot make it public, as any class, without inheriting the LoggerBase cannot use it meaningfully.
Let’s find out why the property named IsThisLogError is public. It may be important/ useful for other associated classes of an inherited class to know whether the associated member logs its errors or not.
Apart from these you can also have virtual methods defined in an abstract class. The virtual method may have its default implementation, where a subclass can override it when required.
All and all, the important factor here is that all OOP concepts should be used carefully with reasons, you should be able to logically explain, why you make a property a public or a field a private or a class an abstract. Additionally, when architecting frameworks, the OOP concepts can be used to forcefully guide the system to be developed in the way framework architect’s wanted it to be architected initially.
4.12. What is an Interface?
In summary the Interface separates the implementation and defines the structure, and this concept is very useful in cases where you need the implementation to be interchangeable. Apart from that an interface is very useful when the implementation changes frequently. Some say you should define all classes in terms of interfaces, but I think recommendation seems a bit extreme.
Interface can be used to define a generic template and then one or more abstract classes to define partial implementations of the interface. Interfaces just specify the method declaration (implicitly public and abstract) and can contain fields and properties (which are also implicitly public and abstract). Interface definition begins with the keyword interface. An interface like that of an abstract class cannot be instantiated.
If a class that implements an interface does not define all the methods of the interface, then it must be declared abstract and the method definitions must be provided by the subclass that extends the abstract class. In addition to this an interfaces can inherit other interfaces.
The sample below will provide an interface for our LoggerBase abstract class.
public interface ILogger
{
bool IsThisLogError { get; }
}
4.13. What is the difference between a Class and an Interface?
In .Net/ C# a class can be defined to implement an interface and also it supports multiple implementations. When a class implements an interface, an object of such class can be encapsulated inside an interface.
If MyLogger is a class, which implements ILogger, there we can write
ILogger log = new MyLogger();
A class and an interface are two different types (conceptually). Theoretically a class emphasis the idea of encapsulation, while an interface emphasis the idea of abstraction (by suppressing the details of the implementation). The two poses a clear separation from one to another. Therefore it is very difficult or rather impossible to have an effective meaningful comparison between the two, but it is very useful and also meaningful to have a comparison between an interface and an abstract class.
4.14. What is the difference between an Interface and an Abstract class?
There are quite a big difference between an interface and an abstract class, even though both look similar.

Interface definition begins with a keyword interface so it is of type interface
Abstract classes are declared with the abstract keyword so it is of type class

Interface has no implementation, but they have to be implemented.
Abstract class’s methods can have implementations and they have to be extended.

Interfaces can only have method declaration (implicitly public and abstract) and fields (implicitly public static)
Abstract class’s methods can’t have implementation only when declared abstract.

Interface can inherit more than one interfaces
Abstract class can implement more than one interfaces, but can inherit only one class

Abstract class must override all abstract method and may override virtual methods
Interface can be used when the implementation is changing
Abstract class can be used to provide some default behavior for a base class.
Interface makes implementation interchangeable
Interface increase security by hiding the implementation
Abstract class can be used when implementing framework
Abstract classes are an excellent way to create planned inheritance hierarchies and also to use as non-leaf classes in class hierarchies.
Abstract classes let you define some behaviors; they force your subclasses to provide others. For example, if you have an application framework, an abstract class can be used to provide the default implementation of the services and all mandatory modules such as event logging and message handling etc. This approach allows the developers to develop the application within the guided help provided by the framework.
However, in practice when you come across with some application-specific functionality that only your application can perform, such as startup and shutdown tasks etc. The abstract base class can declare virtual shutdown and startup methods. The base class knows that it needs those methods, but an abstract class lets your class admit that it doesn't know how to perform those actions; it only knows that it must initiate the actions. When it is time to start up, the abstract class can call the startup method. When the base class calls this method, it can execute the method defined by the child class.
4.15. What is Implicit and Explicit Interface Implementations?
As mentioned before .Net support multiple implementations, the concept of implicit and explicit implementation provide safe way to implement methods of multiple interfaces by hiding, exposing or preserving identities of each of interface methods, even when the method signatures are the same.
Let's consider the interfaces defined below.
interface IDisposable
{
void Dispose();
}
Here you can see that the class Student has implicitly and explicitly implemented the method named Dispose() via Dispose and IDisposable.Dispose.
class Student : IDisposable
{
public void Dispose()
{
Console.WriteLine("Student.Dispose");
}

void IDisposable.Dispose()
{
Console.WriteLine("IDisposable.Dispose");
}
}
4.16. What is Inheritance?
Ability of a new class to be created, from an existing class by extending it, is called inheritance.

public class Exception
{
}


public class IOException : Exception
{
}
According to the above example the new class (IOException), which is called the derived class or subclass, inherits the members of an existing class (Exception), which is called the base class or super-class. The class IOException can extend the functionality of the class Exception by adding new types and methods and by overriding existing ones.
Just like abstraction is closely related with generalization, the inheritance is closely related with specialization. It is important to discuss those two concepts together with generalization to better understand and to reduce the complexity.
One of the most important relationships among objects in the real world is specialization, which can be described as the “is-a” relationship. When we say that a dog is a mammal, we mean that the dog is a specialized kind of mammal. It has all the characteristics of any mammal (it bears live young, nurses with milk, has hair), but it specializes these characteristics to the familiar characteristics of canis domesticus. A cat is also a mammal. As such, we expect it to share certain characteristics with the dog that are generalized in Mammal, but to differ in those characteristics that are specialized in cats.
The specialization and generalization relationships are both reciprocal and hierarchical. Specialization is just the other side of the generalization coin: Mammal generalizes what is common between dogs and cats, and dogs and cats specialize mammals to their own specific subtypes.
Similarly, as an example you can say that both IOException and SecurityException are of type Exception. They have all characteristics and behaviors of an Exception, That mean the IOException is a specialized kind of Exception. A SecurityException is also an Exception. As such, we expect it to share certain characteristic with IOException that are generalized in Exception, but to differ in those characteristics that are specialized in SecurityExceptions. In other words, Exception generalizes the shared characteristics of both IOException and SecurityException, while IOException and SecurityException specialize with their characteristics and behaviors.
In OOP, the specialization relationship is implemented using the principle called inheritance. This is the most common and most natural and widely accepted way of implement this relationship.
4.17. What is Polymorphism?
Polymorphism is a generic term that means 'many shapes'. More precisely Polymorphism means the ability to request that the same operations be performed by a wide range of different types of things.
At times, I used to think that understanding Object Oriented Programming concepts have made it difficult since they have grouped under four main concepts, while each concept is closely related with one another. Hence one has to be extremely careful to correctly understand each concept separately, while understanding the way each related with other concepts.
In OOP the polymorphism is achieved by using many different techniques named method overloading, operator overloading and method overriding,
4.18. What is Method Overloading?
The method overloading is the ability to define several methods all with the same name.
public class MyLogger
{
public void LogError(Exception e)
{
// Implementation goes here
}

public bool LogError(Exception e, string message)
{
// Implementation goes here
}
}
4.19. What is Operator Overloading?
The operator overloading (less commonly known as ad-hoc polymorphism) is a specific case of polymorphism in which some or all of operators like +, - or == are treated as polymorphic functions and as such have different behaviors depending on the types of its arguments.
public class Complex
{
private int real;
public int Real
{ get { return real; } }

private int imaginary;
public int Imaginary
{ get { return imaginary; } }

public
Complex(int real, int imaginary)
{
this.real = real;
this.imaginary = imaginary;
}

public static Complex operator +(Complex c1, Complex c2)
{
return new Complex(c1.Real + c2.Real, c1.Imaginary + c2.Imaginary);
}
}
I above example I have overloaded the plus operator for adding two complex numbers. There the two properties named Real and Imaginary has been declared exposing only the required “get” method, while the object’s constructor is demanding for mandatory real and imaginary values with the user defined constructor of the class.
4.20. What is Method Overriding?
Method overriding is a language feature that allows a subclass to override a specific implementation of a method that is already provided by one of its super-classes.
A subclass can give its own definition of methods but need to have the same signature as the method in its super-class. This means that when overriding a method the subclass's method has to have the same name and parameter list as the super-class's overridden method.
using System;
public class Complex
{
private int real;
public int Real
{ get { return real; } }

private int imaginary;
public int Imaginary
{ get { return imaginary; } }

public Complex(int real, int imaginary)
{
this.real = real;
this.imaginary = imaginary;
}

public static Complex operator +(Complex c1, Complex c2)
{
return new Complex(c1.Real + c2.Real, c1.Imaginary + c2.Imaginary);
}

public override string ToString()
{
return (String.Format("{0} + {1}i", real, imaginary));
}
}
In above example I have extended the implementation of the sample Complex class given under operator overloading section. This class has one overridden method named “ToString”, which override the default implementation of the standard “ToString” method to support the correct string conversion of a complex number.
Complex num1 = new Complex(5, 7);
Complex num2 = new Complex(3, 8);

// Add two Complex numbers using the
// overloaded plus
operator
Complex sum = num1 + num2;

// Print the numbers and the sum
// using the overriden ToString method
Console.WriteLine("({0}) + ({1}) = {2}", num1, num2, sum);
Console.ReadLine();
4.21. What is a Use case?
A use case is a thing a system does. A use case maps actors to functions. Importantly, the actors need not be people.

In another angle a use case encodes a typical user interaction with the system. In particular, it:
Captures some user-visible function.
Achieves some concrete goal for the user.
A complete set of use cases largely defines the requirements for your system: everything the user can see, and would like to do. The below diagram contains a set of use cases that describes a simple login module of a gaming website.

4.22. What is a Class Diagram?
A class diagrams are widely used to describe the types of objects in a system and their relationships. Class diagrams model class structure and contents using design elements such as classes, packages and objects. Class diagrams describe three different perspectives when designing a system, conceptual, specification, and implementation. These perspectives become evident as the diagram is created and help solidify the design.
The Class diagrams, physical data models, along with the system overview diagram are in my opinion the most important diagrams that suite the current day rapid application development requirements.
UML Notations:

4.23. What is a Package Diagram?
Package diagrams are used to reflect the organization of packages and their elements. When used to represent class elements, package diagrams provide a visualization of the namespaces. In my designs, I use the package diagrams to organize classes in to different modules of the system.
4.24. What is a Sequence Diagram?
A sequence diagrams model the flow of logic within a system in a visual manner, it enable both to document and validate your logic, and are used for both analysis and design purposes. Sequence diagrams are the most popular UML artifact for dynamic modeling, which focuses on identifying the behavior within your system.
4.25. What is two-tier architecture?
The two-tier architecture is refers to client/ server architectures as well, the term client/ server was first used in the 1980s in reference to personal computers (PCs) on a network. The actual client/ server model started gaining acceptance in the late 1980s, and later it was adapted to World Wide Web programming.
According to the modern days use of two-tier architecture the user interfaces (or with ASP.NET, all web pages) runs on the client and the database is stored on the server. The actual application logic can run on either the client or the server. So in this case the user interfaces are directly access the database. Those can also be non-interface processing engines, which provide solutions to other remote/ local systems. In either case, today the two-tier model is not as reputed as the three-tier model. The advantage of the two-tier design is its simplicity, but the simplicity comes with the cost of scalability. The newer three-tier architecture, which is more famous, introduces a middle tier for the application logic.

4.26. What is three-tier architecture?
The three tier software architecture (also known as three layer architectures) emerged in the 1990s to overcome the limitations of the two tier architecture. This architecture has aggressively customized and adopted by modern day system designer to web systems.
Three-tier is a client-server architecture in which the user interface, functional process logic, data storage and data access are developed and maintained as independent modules, some time on separate platforms. The term "three-tier" or "three-layer", as well as the concept of multi-tier architectures (often refers to as three-tier architecture), seems to have originated within Rational Software.

The 3-Tier architecture has the following three tiers.
Presentation Tier or Web Server: User Interface, displaying/ accepting data/ input to/ from the user
Application Logic/ Business Logic/ Transaction Tier or Application Server: Data validation, acceptability check before being added to the database and all other business/ application specific operations
Data Tier or Database server: Simple reading and writing method to database or any other storage, connection, command, stored procedures etc
4.27. What is MVC architecture?
The Model-View-Controller (MVC) architecture separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes.
Unfortunately, the popularity of this pattern has resulted in a number of faulty usages; each technology (Java, ASP.NET etc) has defined it in their own way making it difficult to understand. In particular, the term "controller" has been used to mean different things in different contexts. The definitions given bellow are the closes possible ones I found for ASP.NET version of MVC.

Model: DataSet and typed DataSet (some times business object, object collection, XML etc) are the most common use of the model.
View: The ASPX and ASCX files generally handle the responsibilities of the view.
Controllers: The handling of events or the controlling is usually done in the code-behind class.
In a complex n-tier distributed system the MVC architecture place the vital role of organizing the presentation tier of the system.
4.28. What is SOA?
A service-oriented architecture is essentially a collection of services. These services communicate with each other. The communication can involve either simple data passing or it could involve two or more services coordinating some activity. Some means of connecting services to each other is needed.
The .Net technology introduces the SOA by mean of web services.

The SOA can be used as the concept to connect multiple systems to provide services. It has it's great share in the future of the IT world.
According to the imaginary diagram above, we can see how the Service Oriented Architecture is being used to provide a set of centralized services to the citizens of a country. The citizens are given a unique identifying card, where that card carries all personal information of each citizen. Each service centers such as shopping complex, hospital, station, and factory are equipped with a computer system where that system is connected to a central server, which is responsible of providing service to a city. As an example when a customer enter the shopping complex the regional computer system report it to the central server and obtain information about the customer before providing access to the premises. The system welcomes the customer. The customer finished the shopping and then by the time he leaves the shopping complex, he will be asked to go through a billing process, where the regional computer system will manage the process. The payment will be automatically handled with the input details obtain from the customer indentifying card.
The regional system will report to the city (computer system of the city) while the city will report to the country (computer system of the country).
4.29. What is the Data Access Layer?
The data access layer (DAL), which is a key part of every n-tier system, is mainly consist of a simple set of code that does basic interactions with the database or any other storage device. These functionalities are often referred to as CRUD (Create, Retrieve, Update, and Delete).
The data access layer need to be generic, simple, quick and efficient as much as possible. It should not include complex application/ business logics.
I have seen systems with lengthy, complex store procedures (SP), which run through several cases before doing a simple retrieval. They contain not only most part of the business logic, but application logic and user interface logic as well. If SP is getting longer and complicated, then it is a good indication that you are burring your business logic inside the data access layer.
4.30. What is the Business Logic Layer?
I know for a fact that this is a question for most, but from the other hand by reading many articles I have become aware that not everyone agrees to what business logic actually is, and in many cases it's just the bridge in between the presentation layer and the data access layer with having nothing much, except taking from one and passing to the other. In some other cases, it is not even been well thought out, they just take the leftovers from the presentation layer and the data access layer then put them in another layer which automatically is called the business logic layer. However there are no god said things that cannot be changed in software world. You can change as and when you feel comfortable that the method you apply is flexible enough to support the growth of your system. There are many great ways, but be careful when selecting them, they can over complicating the simple system. It is a balance one needs to find with their experience.
As a general advice when you define business entities, you must decide how to map the data in your tables to correctly defined business entities. The business entities should meaningfully define considering various types of requirements and functioning of your system. It is recommended to identify the business entities to encapsulate the functional/ UI (User Interface) requirements of your application, rather than define a separate business entity for each table of your database. For example, if you want to combine data from couple of table to build a UI (User Interface) control (Web Control), implement that function in the Business Logic Layer with a business object that uses couple of data object to support with your complex business requirement.
4.31. What is Gang of Four (GoF) Design Patterns?
The Gang of Four (GoF) patterns are generally considered the foundation for all other patterns. They are categorized in three groups: Creational, Structural, and Behavioral. Here you will find information on these important patterns.
Creational Patterns

Abstract Factory Creates an instance of several families of classes
Builder Separates object construction from its representation
Factory Method Creates an instance of several derived classes
Prototype A fully initialized instance to be copied or cloned
Singleton A class of which only a single instance can exist
Structural Patterns

Adapter Match interfaces of different classes
Bridge Separates an object’s interface from its implementation
Composite A tree structure of simple and composite objects
Decorator Add responsibilities to objects dynamically
Facade A single class that represents an entire subsystem
Flyweight A fine-grained instance used for efficient sharing
Proxy An object representing another object
Behavioral Patterns

Chain of Resp. A way of passing a request between a chain of objects
Command Encapsulate a command request as an object
Interpreter A way to include language elements in a program
Iterator Sequentially access the elements of a collection
Mediator Defines simplified communication between classes
Memento Capture and restore an object's internal state
Observer A way of notifying change to a number of classes
State Alter an object's behavior when its state changes
Strategy Encapsulates an algorithm inside a class
Template Method Defer the exact steps of an algorithm to a subclass
Visitor Defines a new operation to a class without change
Posted by sahil31_mohali at 10:16 AM 0 comments

17.3.09

Create an ASP.NET AJAX ModalPopUp Dynamically

http://www.devcurry.com/2009/02/how-to-create-aspnet-ajax-modalpopup.html

My other blogs

http://computertrickssk.blogspot.com/

http://aspdotnetsk.blogspot.com/

Validating Dropdown List using RequiredFieldValidator

http://www.dotnetfunda.com/codes/code80-validating-dropdown-list-using-requiredfieldvalidator.aspx

Message box javascript in c#

http://dotnetslackers.com/articles/aspnet/JavaScript_with_ASP_NET_2_0_Pages_Part1.aspx

"Textarea/textbox multiline" maxlength validation

http://geekswithblogs.net/mahesh/archive/2007/12/27/asp.net-textbox.multiline-maxlength.aspx

12.3.09

pick usercontrol image on default page

UserControl uc=(UserControl)Page.FindControl("Header1");

Image imgstar = new Image();
imgstar=uc.FindControl("Image1") as Image;
imgstar.ImageUrl = "../App_Themes/ClientHome/images/srar_white.gif";

6.3.09

open popup window

http://www.pageresource.com/jscript/jwinopen.htm

string script = script language='javascript'>window.open('../" + pagename + "','','width=1000,height=750,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');

Radtreeview:checkbox checked

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkbx = (CheckBox)sender;
//GridDataItem item = (GridDataItem)chkbx.NamingContainer;

Label lblPageId1 = (Label)((chkbx.NamingContainer).FindControl("LblPageId"));
int text1 =Convert.ToInt32(lblPageId1.Text);

bool chkSatus1 = chkbx.Checked;

// perform Update operation
int ReturnPageid1 = ObjLogic.UpdateHeaderStatus(text1, chkSatus1);


}


protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkbx = (CheckBox)sender;
//GridDataItem item = (GridDataItem)chkbx.NamingContainer;

Label lblPageId2 = (Label)((chkbx.NamingContainer).FindControl("LblPageIdsub"));
int text2 =Convert.ToInt32(lblPageId2.Text);

bool chkSatus2 = chkbx.Checked;
// perform Update operation
int ReturnPageid2 = ObjLogic.UpdateHeaderStatus(text2, chkSatus2);
}

Loop through RadTreeview

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)


{
if (Request.QueryString["pageid"] != null)
{
ViewState["pageid"] = Request.QueryString["pageid"].ToString();


}
TreeBind(null, 0);
}
}

private void TreeBind(RadTreeNode n, int PageId)
{

DataSet ObjdsPage = (DataSet)ObjLogic.DisplayPagesByPrntIdnew(PageId);
if (ObjdsPage.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ObjdsPage.Tables[0].Rows.Count; i++)
{

RadTreeNode node = new RadTreeNode(ObjdsPage.Tables[0].Rows[i][0].ToString(), ObjdsPage.Tables[0].Rows[i][1].ToString());
TreeBind(node, Convert.ToInt32(ObjdsPage.Tables[0].Rows[i][1].ToString()));
if (n == null)
{
radtreepage.Nodes.Add(node);
}
else
{
n.Nodes.Add(node);
}
}
}
}
protected void radtreepage_NodeClick(object o, RadTreeNodeEventArgs e)
{
//int flag = 1;

if (radtreepage.SelectedNode.Value != "0")
{

Session["Value"] = radtreepage.SelectedNode.Value.ToString();
Session["NodeText"] = radtreepage.SelectedNode.Text.ToString();

}
radtreepage.SelectedNode.Selected = false;

}
protected void radtreepage_NodeCheck(object o, RadTreeNodeEventArgs e)
{
if (ViewState["pageid"] != null)
{
pageId = Convert.ToInt32(ViewState["pageid"].ToString());

}
else
{
pageId = -2;
}


int PageParentValue =Convert.ToInt32(e.NodeChecked.Value);

string NodeText = e.NodeChecked.Text;

bool PageCheck = e.NodeChecked.Checked;

if (PageCheck == true)
{
relation = -1;
//insert Relation
ObjLogic.InsertUpdatePagesRelation(pageId, PageParentValue, relation);

}
else if (PageCheck == false)
{
relation = 0;
//delete Relation
ObjLogic.InsertUpdatePagesRelation(pageId, PageParentValue, relation);

}

// Response.Redirect("View.aspx?pagename="+NodeText);

//frm_control.Attributes["src"] = "View.aspx?pagename=" + NodeText;
}

4.3.09

File Use

private void CreateASPX()
{
if (ddltopic.SelectedValue == "0")
{
if (ddltemplate.SelectedItem.Value == "MipservMaster")
{
VarApptheme = "MipservTheme";
}
else if (ddltemplate.SelectedItem.Value == "MipservHome")
{
VarApptheme = "mipservhome";
}
string filename = Server.MapPath("../");
filename += txtpname.Value + ".aspx";
FileInfo fileinfo = new FileInfo(filename);
if (fileinfo.Exists == false)
{
FileStream filestr = new FileStream(filename, FileMode.CreateNew, FileAccess.Write, FileShare.Read);
StreamWriter sw = new StreamWriter(filestr);


sw.WriteLine("<%@ Page Language='C#' AutoEventWireup='true' MasterPageFile='~/Templates/" + ddltemplate.SelectedItem.Value + ".master' CodeFile=' " + txtpname.Value + ".aspx.cs' Inherits='" + txtpname.Value + "'" + " " + "Theme=" + '"' + VarApptheme + '"' + " %>");

sw.WriteLine("<%@ Register src='~/UserControls/UCTopics.ascx' tagname='UCTopics' tagprefix='ucl' %>");
sw.WriteLine("");
sw.WriteLine("");
sw.WriteLine("
");
sw.Flush();
sw.Close();


}
else
{
string strJavaScript;

}
}
else
{

if (ddltemplate.SelectedItem.Value == "MipservMaster")
{
VarApptheme="MipservTheme";
}
else if(ddltemplate.SelectedItem.Value == "MipservHome")
{
VarApptheme = "mipservhome";
}

string filename = Server.MapPath("../");
filename += txtpname.Value + ".aspx";
FileInfo fileinfo = new FileInfo(filename);
if (fileinfo.Exists == false)
{
FileStream filestr = new FileStream(filename, FileMode.CreateNew, FileAccess.Write, FileShare.Read);
StreamWriter sw = new StreamWriter(filestr);


sw.WriteLine("<%@ Page Language='C#' AutoEventWireup='true' MasterPageFile='~/Templates/" + ddltemplate.SelectedItem.Value + ".master' CodeFile=' " + txtpname.Value + ".aspx.cs' Inherits='" + txtpname.Value + "'" + " " + "Theme=" + '"' + VarApptheme + '"' + " %>");

sw.WriteLine("<%@ Register src='~/UserControls/UCTopics.ascx' tagname='UCTopics' tagprefix='ucl' %>");
sw.WriteLine("");
sw.WriteLine("");
sw.WriteLine("
");
sw.Flush();
sw.Close();

}
}
}
private void CreateASPXCS()
{
string filename = Server.MapPath("../");
filename += txtpname.Value + ".aspx.cs";
FileInfo fileinfo = new FileInfo(filename);
if (fileinfo.Exists == false)
{
FileStream filestr = new FileStream(filename, FileMode.CreateNew, FileAccess.Write, FileShare.Read);
CreateASPX();
StreamWriter sw = new StreamWriter(filestr);
sw.WriteLine("using System.Data;");
sw.WriteLine("using System.Collections;");
sw.WriteLine("using System.Configuration;");
sw.WriteLine("using System.Web;");
sw.WriteLine("using System;");
sw.WriteLine("using System.Web.UI;");
sw.WriteLine("using System.Web.UI.HtmlControls;");
sw.WriteLine("using System.Web.UI.WebControls;");
sw.WriteLine("public partial class " + txtpname.Value + " : System.Web.UI.Page");
sw.WriteLine("{");
sw.WriteLine("protected void Page_Load(object sender, EventArgs e)");
sw.WriteLine("{");

sw.WriteLine("Page.Header.Title =" +'"' + txttitle.Value +'"'+";");
sw.WriteLine("HtmlHead head = (HtmlHead)Page.Header;");
sw.WriteLine("HtmlMeta KeywordMeta = new HtmlMeta();");

sw.WriteLine("KeywordMeta.Attributes.Add(" + '"' + "Meta Description" + '"' + ',' + '"' + txtkey.Value + '"' + ");");
sw.WriteLine("KeywordMeta.Attributes.Add(" + '"' + "Meta Keywords" + '"' + ',' + '"' + txtkey.Value + '"' + ");");


sw.WriteLine(" head.Controls.Add(KeywordMeta);");
sw.WriteLine("}");
sw.WriteLine("}");
sw.Flush();
sw.Close();
}
else
{
string strJavaScript;

}
}

datalist contain Repeator

private void DisplayHomeDataHeader()
{
DataSet objds = ObjLogic.DisplayPagesdataByPrntIdHome(0);
if (objds.Tables[0].Rows.Count > 0)
{
DataHome.DataSource = objds;
DataHome.DataBind();

}
}


protected void DataHome_ItemDataBound(object sender, DataListItemEventArgs e)
{
DataSet objds = ObjLogic.DisplayPagesdataByPrntIdHomesub(Convert.ToInt32(DataHome.DataKeys[e.Item.ItemIndex]));
if (objds.Tables[0].Rows.Count > 0)
{
Repeater r = ((Repeater)e.Item.FindControl("RepSubHome"));
r.DataSource = objds;
r.DataBind();

}
}
===================================

asp:DataList ID="DataHome" runat="server" DataKeyField="cms_page_fk"
RepeatDirection="Horizontal" onitemdatabound="DataHome_ItemDataBound" RepeatColumns="4">
ItemTemplate>
div class="panel">
a href= '<%# "../" +Eval("cms_page_name")%>' alt="" runat="server" class="aremove">
asp:Label ID="LblHeader" runat="server" Text='<%# Eval("cms_page_show")%>' CssClass="panel-head"asp:Label/a>


div class="container">
div style="width: 155px; margin: 0 auto; margin-top: 3px;">
asp:Image ID="ImgHome" runat="server" Width="155px" Height="61px" ImageUrl='<%#"../App_Themes/mipservhome/images/"+ Eval("cms_page_image")%>' alt=""/>
/div>
asp:Repeater id="RepSubHome" runat="server" >


ItemTemplate>


table width="95%" border="0" align="center" cellpadding="1" cellspacing="1" style="margin-top: 2px">
tr>
td valign="top" style="width: 3px">
height="11" />
/td>
td class="left-li">
a id="A1" href= '<%# "../" +Eval("cms_page_name")%>' alt="" runat="server">
asp:Label ID="LblSub" runat="server" Text='<%# Eval("cms_page_show")%>'>
/a>
/td>
/tr>


/table>

/ItemTemplate>

/asp:Repeater>
/div

ItemTemplate


asp:DataList