1 Replies - 1190 Views - Last Post: 09 June 2010 - 11:57 PM Rate Topic: -----

#1 Needanswer   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 61
  • Joined: 27-January 10

gridview1_updating on vwd 2008 express with access

Posted 08 June 2010 - 08:34 PM

This prorgam:

edit select delet id etc


outside/under the gridview1

textbox1
textbox2

addbutton cancelbutton



 <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
        AutoGenerateColumns="False" DataKeyNames="id"  
            BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" 
            CellPadding="3" GridLines="Vertical" >
            <RowStyle BackColor="#EEEEEE" ForeColor="Black"/>
            <Columns>
                <asp:TemplateField ShowHeader="False">
                 <EditItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="True"CommandName="Update"Text="Update" />               
&nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False" 
                            CommandName="Cancel" Text="Cancel" />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Button ID="Button1" runat="server" CausesValidation="False" 
                            CommandName="Edit" Text="Edit" />
                        &nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False" 
                            CommandName="Select" Text="Select" />
                        &nbsp;<asp:Button ID="Button3" runat="server" CausesValidation="False" 
                            CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure');"/>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" 
                    ReadOnly="True" SortExpression="id" Visible="False" />
                <asp:BoundField DataField="sysaccount" HeaderText="sysaccount" 
                    SortExpression="sysaccount" />
                <asp:BoundField DataField="syspw" HeaderText="syspw" SortExpression="syspw" />
                <asp:BoundField DataField="log" HeaderText="log" SortExpression="log" />
            </Columns>
            <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
            <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="#DCDCDC" />
        </asp:GridView>




This is add.
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim con1 As New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:\Users\user\Desktop\honor.mdb")
        Dim sqlinsert As String

        sqlinsert = "INSERT INTO sysdep (sysaccount,syspw)" & _
          "VALUES(@sysaccount, @syspw)"

        Dim cmd As New OleDbCommand(sqlinsert, con1)

        cmd.Parameters.Add(New OleDbParameter("@sysaccount", TextBox1.Text))
        cmd.Parameters.Add(New OleDbParameter("@syspw", TextBox2.Text))

        Try
            con1.Open()
            cmd.ExecuteNonQuery()
        Catch ex As OleDbException
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Web")
        Catch ex As InvalidOperationException
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Web")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Web")
        End Try

        con1.Close()
        BindGridView()

    End Sub




I got the delete, add, cancel, add all working, except gridview_updating, not for sure? Thanks.

This post has been edited by Needanswer: 08 June 2010 - 08:44 PM


Is This A Good Question/Topic? 0
  • +

Replies To: gridview1_updating on vwd 2008 express with access

#2 Needanswer   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 61
  • Joined: 27-January 10

Re: gridview1_updating on vwd 2008 express with access

Posted 09 June 2010 - 11:57 PM

[quote name='Needanswer' date='08 June 2010 - 07:34 PM' timestamp='1276054487' post='1037448']
This prorgam:

edit select delet id etc


outside/under the gridview1

textbox1
textbox2

addbutton cancelbutton



 <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
        AutoGenerateColumns="False" DataKeyNames="id"  
            BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" 
            CellPadding="3" GridLines="Vertical" >
            <RowStyle BackColor="#EEEEEE" ForeColor="Black"/>
            <Columns>
                <asp:TemplateField ShowHeader="False">
                 <EditItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="True"CommandName="Update"Text="Update" />               
&nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False" 
                            CommandName="Cancel" Text="Cancel" />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Button ID="Button1" runat="server" CausesValidation="False" 
                            CommandName="Edit" Text="Edit" />
                        &nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False" 
                            CommandName="Select" Text="Select" />
                        &nbsp;<asp:Button ID="Button3" runat="server" CausesValidation="False" 
                            CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure');"/>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" 
                    ReadOnly="True" SortExpression="id" Visible="False" />
                <asp:BoundField DataField="sysaccount" HeaderText="sysaccount" 
                    SortExpression="sysaccount" />
                <asp:BoundField DataField="syspw" HeaderText="syspw" SortExpression="syspw" />
                <asp:BoundField DataField="log" HeaderText="log" SortExpression="log" />
            </Columns>
            <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
            <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="#DCDCDC" />
        </asp:GridView>




This is add.
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim con1 As New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:\Users\user\Desktop\honor.mdb")
        Dim sqlinsert As String

        sqlinsert = "INSERT INTO sysdep (sysaccount,syspw)" & _
          "VALUES(@sysaccount, @syspw)"

        Dim cmd As New OleDbCommand(sqlinsert, con1)

        cmd.Parameters.Add(New OleDbParameter("@sysaccount", TextBox1.Text))
        cmd.Parameters.Add(New OleDbParameter("@syspw", TextBox2.Text))

        Try
            con1.Open()
            cmd.ExecuteNonQuery()
        Catch ex As OleDbException
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Web")
        Catch ex As InvalidOperationException
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Web")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Web")
        End Try

        con1.Close()
        BindGridView()

    End Sub




I got the delete, add, cancel, add all working, except gridview_updating, not for sure? Thanks.
[/quot]

It is working now.

This post has been edited by Needanswer: 10 June 2010 - 06:51 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1