Wednesday, August 31, 2011

Deleting Selected row from gridview in asp.net, vb.net

1.add a buttonfield in grid view set command name as "Delete" then add this code

Imports System.Data
Imports System.Data.OleDb
Imports System.Web
Imports System.Web.UI.WebControls
Imports System.IO

Partial Class _Default
    Inherits System.Web.UI.Page
    Public con As OleDbConnection
    Public cmd As OleDbCommand
    Public da As OleDbDataAdapter
    Public dr As OleDbDataReader
    Public ds As DataSet
    Public cmb As OleDbCommandBuilder



Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
        con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("youraccessdatabase/db.mdb") & "")
        con.Open()
        da = New OleDbDataAdapter("select * from cust_details order by ID desc", con)
        ds = New DataSet()
        cmb = New OleDbCommandBuilder(da)
        da.Fill(ds)
        ds.Tables.Item(0).Rows.Item(e.RowIndex).Delete()
        da.Update(ds)
        GridView1.DataSource = ds
        GridView1.DataBind()
    End Sub

End Class

Saturday, August 27, 2011

Creating a temporary table in vb.net and binding to a gridview

This is a example that how to create temporary table in  vb.net

**************************
Imports System.Data



Partial Class _Default
    Inherits System.Web.UI.Page
    Public table1 As DataTable
    Public ds As DataSet

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        table()

    End Sub
    Public Function table()
        Try
            table1 = New DataTable
            table1.Columns.Add("rollno", Type.GetType("System.Int32"))
            table1.Columns.Add("name", Type.GetType("System.String"))
            table1.Columns.Add("result", Type.GetType("System.String"))

            Dim editrow As DataRow
            editrow = table1.NewRow
            editrow(0) = 41
            editrow(1) = "lalit kumar"
            editrow(2) = "Pass"
            table1.Rows.Add(editrow)
            ds = New DataSet
            ds.Tables.Add(table1)
            GridView1.DataSource = ds
            GridView1.DataBind()

        Catch ex As Exception
            Response.Write(ex.Message)

        End Try
    End Function
End Class

****************************

Thursday, August 25, 2011

Print A Web Page Javascript


It is just a small function name window.print() you need to call on a button click:-
<input type="button" name="Print" value="Print" onclick="window.print();" />






No need to write anything else

Wednesday, August 24, 2011

General Page Life-cycle Stages

In general terms, the page goes through the stages outlined in the following table. In addition to the page life-cycle stages, there are application stages that occur before and after a request but are not specific to a page..




Stage Description
Page request The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.
Start In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostback property. Additionally, during the start step, the page's UICulture property is set.
Page initialization During page initialization, controls on the page are available and each control's UniqueID property is set. Any themes are also applied to the page. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.
Load During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state.
Validation During validation, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.
Postback event handling If the request is a postback, any event handlers are called.
Rendering Before rendering, view state is saved for the page and all controls. During the rendering phase, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream of the page's Response property.
Unload Unload is called after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed.

Thursday, August 18, 2011

Welcome






Hello friends my name Lalit Kumar and this my blog to update my recent achievements. First of all i want to tell something about me .

If i talk about my educational background i have completed BCA,MCA and certification in .net 3.5.

In concern to my professional background from two years i am in this industry and currently i am working with Dreamtree Educare Pvt. Ltd..
MY key skills are c#,vb.net,xml,ms-sql,html,css,java,javascript and i am still trying to improve myself.
Here are some live projects i have worked.