Guest User

Untitled

a guest
Jun 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. DELETE * FROM Portfolio WHERE PortfolioID = @PortfolioID
  2.  
  3. <asp:GridView ID="myGrid" runat="server" DataKeyNames='PortfolioID' OnRowCommand="dgStudent_RowCommand">
  4. <Columns>
  5. <asp:ButtonField ButtonType="Button" CommandName="Delete" Text="Delete"></asp:ButtonField>
  6. </Columns>
  7. </asp:GridView>
  8.  
  9. protected void myGrid_RowCommand(object sender, GridViewCommandEventArgs e)
  10. {
  11. // create and open DB connection
  12. int PortfolioID = (int)myGrid.DataKeys[Convert.ToInt32(e.CommandArgument)].Value;
  13. DeleteRow(PortfolioID); // your implementation
  14. myGrid.DataBind();
  15. }
  16.  
  17. private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  18. {
  19.  
  20. this.txt_portfolioId.Text=dataGridView1.CurrentRow.Cells["portfolioID"].Value.ToString();
  21.  
  22.  
  23. }
  24.  
  25.  
  26. private void btn_Delete(object sender, EventArgs e)
  27. {
  28.  
  29. //You need to connect to database(regular database connection this connection string and sqlcommand and add this sqlquerry:
Add Comment
Please, Sign In to add comment