Inside a button link database with gridview .

protected void Button2_Click(object sender, EventArgs e)
    {
        string strSQLconnection = "Data Source=ABC-0D30299B90A;Initial Catalog=JAPIT;Integrated Security=True";
        SqlConnection sqlConnection = new SqlConnection(strSQLconnection);
        SqlCommand sqlCommand = new SqlCommand("select  *   from   Doe_detail", sqlConnection);
        sqlConnection.Open();

        SqlDataReader reader = sqlCommand.ExecuteReader();

        GridView1.DataSource = reader;
        GridView1.DataBind();
    }

For edit and update and cancel i write write what for delete ????

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="doe_id" DataSourceID="SqlDataSource1">
        <Columns>
            <asp:BoundField DataField="doe_id" HeaderText="doe_id" ReadOnly="True" 
                SortExpression="doe_id" />
            <asp:BoundField DataField="doe_name" HeaderText="doe_name" 
                SortExpression="doe_name" />
            <asp:BoundField DataField="doe_father_name" HeaderText="doe_father_name" 
                SortExpression="doe_father_name" />
            <asp:BoundField DataField="phone" HeaderText="phone" SortExpression="phone" />
            <asp:BoundField DataField="email" HeaderText="email" SortExpression="email" />
            <asp:BoundField DataField="Dept_name" HeaderText="Dept_name" 
                SortExpression="Dept_name" />
            <asp:CommandField ShowEditButton="True" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:JAPITConnectionString %>" 
        SelectCommand="SELECT * FROM [Doe_detail]" 
        
        UpdateCommand="UPDATE Doe_detail SET  doe_name = @doe_name, doe_father_name = @doe_father_name, phone = @phone, email = @email, Dept_name = @Dept_name WHERE (doe_id = @doe_id)" 
        InsertCommand="INSERT INTO Doe_detail(doe_id, doe_name, doe_father_name, phone, email, Dept_name) VALUES (@d_id, @dn, @df, @ph, @em, @de)">
        <UpdateParameters>
            <asp:Parameter Name="doe_name" />
            <asp:Parameter Name="doe_father_name" />
            <asp:Parameter Name="phone" />
            <asp:Parameter Name="email" />
            <asp:Parameter Name="dept_name" />
            <asp:Parameter Name="doe_id" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="d_id" />
            <asp:Parameter Name="dn" />
            <asp:Parameter Name="df" />
            <asp:Parameter Name="ph" />
            <asp:Parameter Name="em" />
            <asp:Parameter Name="de" />
        </InsertParameters>
    </asp:SqlDataSource>
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.