Narasiman nar

Narasiman nar

  • NA
  • 64
  • 22.1k

How to update selected checkbox row to database from gridvie

Jun 14 2018 12:23 AM
My code as follows
  1. protected void Page_Load(object sender, EventArgs e)  
  2. {  
  3. if (!IsPostBack)  
  4. {  
  5. BindData();  
  6. }  
  7. }  
  8. protected void BindData()  
  9. {  
  10. String strConnString = ConfigurationManager.ConnectionStrings["ConnectionStrings"].ConnectionString;  
  11. SqlConnection con = new SqlConnection(strConnString);  
  12. SqlCommand cmd = new SqlCommand("select * from [transact].[transaction_item] where status = 'new'", con);  
  13. con.Open();  
  14. SqlDataAdapter da = new SqlDataAdapter();  
  15. DataSet ds = new DataSet();  
  16. da.SelectCommand = cmd;  
  17. da.Fill(ds);  
  18. grdRpt.DataSource = ds;  
  19. grdRpt.DataBind();  
  20. }  
  21. protected void grdRpt_PageIndexChanging(object sender, GridViewPageEventArgs e)  
  22. {  
  23. grdRpt.PageIndex = e.NewPageIndex;  
  24. BindData();  
  25. }  
when i run the above code output as follows
selectdata    transactid transactitemtype transactorgin status
Checkbox    1                123                   IVC                New
Checkbox    2                245                   IVC                New
Checkbox    3                345                   IVC                New
Checkbox    4                645                   IVC                New
Checkbox    5                723                   IVC                New
Checkbox    6                445                   IVC                New
Checkbox    7                545                   IVC                New
Checkbox    8                923                   IVC                New
Checkbox    9                245                   IVC                New
Checkbox    10              845                   IVC                New
 
1 2
 
1 and 2 paging will be there in the gridview
 
in first page five records will displayed and in the second page another five records will displayed.
 
suppose in the first page i check two rows and in the second page i check two rows means that selected check box rows to update in the [transact].[transaction_item] in the table.
 
for that how to do using c#.

Answers (2)