Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have a requirement in my project that if the user clicks the disable button inside the grid view, the record will be disabled. That record will not anymore appear in the grid view but it should NOT be deleted in the database.Each record in the grid view has their own Disable button. How to make that? I am new in Asp.Net
Posted
Updated 27-Jul-14 15:14pm
v3

read documentation of GridView.RowCommand Event[^]
in your database add another column to save disable status of the record. when you load you can load only the enabled rows. on disable button click you can update database record as disabled.
 
Share this answer
 
Comments
DarkDreamer08 27-Jul-14 22:57pm    
can you show me some codes about it, please :)
DamithSL 27-Jul-14 23:09pm    
you need to try, see the last example in the given link
DarkDreamer08 27-Jul-14 23:23pm    
actually, I am trying that last example. but i am wondering and really got confused on some things in the last example of your given link to me. like the e.CommandName=="Increase", What is that 'Increase'? taht is why I am asking for some short codes for it. Hope you understand since I am a new in this language. Thank you so much.
DamithSL 27-Jul-14 23:24pm    
in your button you need to set command name property, here you have CommandName="Increase"
Thanks7872 28-Jul-14 1:51am    
Asking questions like this is merely a waste of time. You are expected to try something your self. Don't you have access to google.com? If you just read about rowcommand event everything will be clear to you.
You can add a IsActive bit to you database table
when you disable a record, the bit is set to 0(false) else it is 1(true)
now just add a disable button to the grid and write the code against the gridview event handler event for the disable button

You can read all about gridview event handlers here GridView [^]
 
Share this answer
 
Comments
DarkDreamer08 27-Jul-14 22:58pm    
please, show me some codes about it XD
 
Share this answer
 
I would recommend you to follow the steps:
Steps:
1. Keep an Indicator "IsDisable"(Type : Boolean) in your DataSource of GridView.
2. Set that indicator to false by default.
3. OnRowCommand event of GridView, set the indicator to true in your datasource.
4. While binding GridView filter the DataSource with IsDisable value.



   --Amy
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900