hi iam insert the data into data base at run time through grid view .....
here iam write the coding but there is no errors.........
here the problem is the grid view is can't be displayed at run time...........
pls help me very urgent....
here my coding is given below..........

<asp:GridView ID="GridView1" runat="server" style="z-index: 100; left: 44px; position: absolute; top: 41px" AutoGenerateColumns="False">
        <Columns >
        <asp:TemplateField HeaderText="gp_no">
                    <ItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("gp_no") %>' Width="82px"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="year">
                    <ItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("year") %>' Width="82px"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="sno">
                    <ItemTemplate>
                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("sno") %>' Width="82px"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="description">
                    <ItemTemplate>
                        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("description") %>' Width="65px"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="make">
                    <ItemTemplate>
                        <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("make") %>'></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="equip_no">
                    <ItemTemplate>
                        <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("equip_no") %>'></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="qty">
                    <ItemTemplate>
                        <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("qty") %>' Width="82px"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="total_packets">
                    <ItemTemplate>
                        <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("total_packets") %>' Width="82px"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
        </Columns>
        </asp:GridView>



Imports System
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.SqlClient

Partial Public Class _gate
    Inherits System.Web.UI.Page
    Private strgp_no As String
    Private intyear As Integer
    Private intsno As Integer
    Private strdescription As String
    Private strmake As String
    Private strequip_no As String
    Private intqty As Integer
    Private inttotal_packets As Integer
    Dim cnn As New SqlConnection(ConfigurationManager.ConnectionStrings("guest2").ConnectionString())
    Dim cmd As SqlCommand

    Public Property gp_no() As String
        Get
            Return strgp_no
        End Get
        Set(ByVal value As String)
            strgp_no = value
        End Set
    End Property

    Public Property year() As String
        Get
            Return CStr(intyear)
        End Get
        Set(ByVal value As String)
            intyear = CInt(value)
        End Set
    End Property

    Public Property sno() As String
        Get
            Return CStr(intsno)
        End Get
        Set(ByVal value As String)
            intsno = CInt(value)
        End Set
    End Property

    Public Property description() As String
        Get
            Return strdescription
        End Get
        Set(ByVal value As String)
            strdescription = value
        End Set
    End Property

    Public Property make() As String
        Get
            Return strmake
        End Get
        Set(ByVal value As String)
            strmake = value
        End Set
    End Property

    Public Property equip_no() As String
        Get
            Return strequip_no
        End Get
        Set(ByVal value As String)
            strequip_no = value
        End Set
    End Property

    Public Property qty() As String
        Get
            Return CStr(intqty)
        End Get
        Set(ByVal value As String)
            intqty = CInt(value)
        End Set
    End Property

    Public Property total_packets() As String
        Get
            Return CStr(inttotal_packets)
        End Get
        Set(ByVal value As String)
            inttotal_packets = CInt(value)
        End Set
    End Property

    Private Sub BindGrid()
        Dim items As New List(Of _gate)(8)
        For i As Integer = 0 To 7
            Dim c As New _gate()
            Items.Add(c)
        Next
        GridView1.DataSource = items
        GridView1.DataBind()
        GridView1.Dispose()
    End Sub

    Private Sub BeginAdd()
        cnn.Open()
        Dim tran As SqlTransaction = cnn.BeginTransaction()
        'Dim str
        'str = "insert into customers(gp_no,year,sno,description,make,equip_no,qty,total_packets) values(@gp_no,@year,@sno,@description,@make,@equip_no,@qty,@total_packets)"
        'adp = New SqlDataAdapter(str, cnn)
        'adp.Fill(ds, "gatein_item")
        'GridView1.DataSource = ds
        'GridView1.DataBind()
        'GridView1.Dispose()
        cmd.Connection = cnn
        cmd.Transaction = tran
        cmd.CommandText = "insert into customers(gp_no,year,sno,description,make,equip_no,qty,total_packets) values(@gp_no,@year,@sno,@description,@make,@equip_no,@qty,@total_packets)"
        Dim p1 As New SqlParameter("@gp_no", SqlDbType.VarChar)
        Dim p2 As New SqlParameter("@year", SqlDbType.Int)
        Dim p3 As New SqlParameter("@sno", SqlDbType.Int)
        Dim p4 As New SqlParameter("@description", SqlDbType.VarChar)
        Dim p5 As New SqlParameter("@make", SqlDbType.VarChar)
        Dim p6 As New SqlParameter("@equip_no", SqlDbType.VarChar)
        Dim p7 As New SqlParameter("@qty", SqlDbType.Int)
        Dim p8 As New SqlParameter("@total_packets", SqlDbType.Int)
        cmd.Parameters.Add(p1)
        cmd.Parameters.Add(p2)
        cmd.Parameters.Add(p3)
        cmd.Parameters.Add(p4)
        cmd.Parameters.Add(p5)
        cmd.Parameters.Add(p6)
        cmd.Parameters.Add(p7)
        cmd.Parameters.Add(p8)
    End Sub

    Private Sub CompleteAdd()
        Try
            cmd.Transaction.Commit()
            MsgBox("data added successfully")
        Catch ex As Exception
            MsgBox("data is not added")
        Finally
            cnn.Close()
        End Try
    End Sub

    Private Sub AddCustomer(ByVal custid As String, ByVal company As String, ByVal contact As String, ByVal country As String)
        Dim gp_no, year, sno, equip_no, qty, total_packets As Integer
        Dim description, make As String
        Try
            cmd.Parameters(0).Value = gp_no
            cmd.Parameters(1).Value = year
            cmd.Parameters(2).Value = sno
            cmd.Parameters(3).Value = description
            cmd.Parameters(4).Value = make
            cmd.Parameters(5).Value = equip_no
            cmd.Parameters(6).Value = qty
            cmd.Parameters(7).Value = total_packets
            cmd.ExecuteNonQuery()
        Catch
            cmd.Transaction.Rollback()
        End Try
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        If Not IsPostBack Then
            Call BindGrid()
        End If
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles save.Click
        Call BeginAdd()
        For Each row As GridViewRow In GridView1.Rows
            If row.RowType = DataControlRowType.DataRow Then
                Dim gp_no As String = DirectCast(row.FindControl("TextBox1"), TextBox).Text
                Dim year As String = DirectCast(row.FindControl("TextBox2"), TextBox).Text
                Dim sno As String = DirectCast(row.FindControl("TextBox3"), TextBox).Text
                Dim description As String = DirectCast(row.FindControl("TextBox4"), TextBox).Text
                Dim make As String = DirectCast(row.FindControl("TextBox5"), TextBox).Text
                Dim equip_no As String = DirectCast(row.FindControl("TextBox6"), TextBox).Text
                Dim qty As String = DirectCast(row.FindControl("TextBox7"), TextBox).Text
                Dim total_packets As String = DirectCast(row.FindControl("TextBox8"), TextBox).Text
            End If
        Next
        CompleteAdd()
    End Sub
    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs)
        Call BindGrid()
    End Sub
End Class

pls help me very urgent.............
plssssssssss

I am seeing you commented the bind part,is this right code

'adp.Fill(ds, "gatein_item")        'GridView1.DataSource = ds        'GridView1.DataBind()        'GridView1.Dispose()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.