Delete (Hide) Row from Gridview without deleting from DataBase

I am populating some data in a GridView.
I added a column with a checkbox.
Now I want to generate a sort of print-preview...
When Ich check some buttons and hit my printpriview button.
I only want these (selected rows displayed).
How can I do this?
The checkbox thing is already working What I basically need is something to delete data temporaly from a GridView (not Database).

I tryed GridViewRow.Dispose() which worked but then the paging was still implementet and the user sees still all pages =(
I have tryed GridViewRow.Enabled = false which only turned the colors =(
I have used GridViewRow.Visible = false which worked for hiding the rows but still left all the links for paging.
I have used GridView1.deleteRow(GridViewRow.RowIndex) which causes an exception because deleting is not implemented in my SqlDataSource...

So if I could not realy delete the row is it possible to update the the paging links numbers....

Any help would be appriciated ...

10/28/2005 8:58:07 AM 72751 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 35

You can for example hook up to the RowDataBound event of the GridView and hide the rows and make sure to turn of paging, or get all the key value of the selected rows and get the selected data from your data source and only bind them to the GridView.
/Fredrik Normén - fredrikn @ twitter

Microsoft MVP, MCSD, MCAD, MCT

My Blog
10/28/2005 11:41:24 AM
Is this only possible if paging is disabled?
10/28/2005 12:25:38 PM

No one here to help me on this one?

If have  tried to put this in the RowDataBound event but it won't work.
Because the gridview is already bound.

I have it that way I bind a grid to a datasource and then I select all my values which I like to keep in the list.
(Checkbox is solved with templateItem).
Then I have a button which is called Printpreview. Clicking on that button fires the click event.
Now I can determ all the selected values but I cannot turn of paging.

I tried another way:
In the printview button clickevent method I save I value for printview then I call GridView1.DataBind().
And in the  RowDataBound event Method I can not determ my selected value because it is not present anymore (caused by the rebind).

What I would like to have is that I could select values from the gridview (even with paging) and hit the printview button an see one list with all the selected values. (But nothing will get deleted in the database).

I hope somebody finds the time to look over this post and could provide me some help...


11/1/2005 12:16:15 PM

well, here's something that might work: handle the click event of the buttons and got through all the rows. if the checkbox is checked, then you can add the ID of that element to an array list.

at the end, you'lljust have to build a new sql expression that returns only those values (you can use the IN clause: select * from table1 where id in (1, 2, 3, ....) ). then you´ll have to rebind this to the grid explicitly.

Luis Abreu
EN blog:
11/1/2005 1:53:06 PM

Similar Artilces:

How to delete controls in GridView when the delete button in a row is clicked
Hi,   I am having issues with my gridview.....i added 2 dropdown and 2 compare validators....whenever i delete a row though......the dropdown and compare validators are becoming null........thus when i click a button, it is still validating.............anyway to delete this when i click the delete button or even handle?   Please help.  ...

DataSet rows being deleted, but after the update , the sql database is not updated. The delete rows still in the database.
 Stepping thru the code with the debugger shows the dataset rows being deleted.   After executing the code, and getting to the page presentation. Then I stop the debug and start the page creation process again ( Page_Load ).    The database still has the original deleted dataset rows. Adding rows works, then updating works fine, but deleting rows, does not seem to work.   The dataset is configured to send the DataSet updates to the database. Use the standard wizard to create the dataSet.     cDependChildTA.Fill(cDependChildDs._ClientDependentC...

Delete Row from Gridview (without saving Database)
Hi, I created a GridView to do a where statement and using a  SqlDataSource1 to connect the table. However, I want to use a delete button to temporary remove the entire row only, no need update the table. What can I do? <asp:GridView ID="GridView1" runat="server"  AutoGenerateColumns="False"   ShowFooter="True"                     DataKeyNames="id" DataSourceID="SqlDataSource1">    &n...

Client-Side Delete from Gridview(Hide-row and delete when page is saved)
Is there any way to hide a row dynamically in a gridview without a postback?  Each row in my grid has a delete button.  When the delete button is pressed I want it to appear to the user as if the corresponding row has been deleted.   The delete won't actually take place until there is a postback.  I am using and javascript.  Here is a stripped down version of what I have.    <script type="text/javascript" > function getParentObjectId(fromId) { var str; var indx; indx = fromId.lastIndexOf("_"); str = fr...

delete row or delete all in Gridview?
Hi there, I have a Gridview that bind the data from the .mdb  and I want to have 2 delete buttions, one is delete a row and the other one is delete all from the database.  How do I do it in code behind in c#?  thanks a lot row delete  (temp call rowDel) all delete (temp call allDel) with rowDel: i think you should bound one column in gridview  (or datagrid)<asp:ButtonColumn... and bout allDel: i think you should use a button distinct with gridview.Becoz your required is not complex , when allDel be push you don't care...

When I delete something in my GridView, my data is delete in the database but not on my GridView
I've got a GridView, when I click on the delete button, my data is deleted in the database but not on my GridView. When I press on F5 for refresh my browser, my datarow is deleted. So is it possible the clear the cache of the GridView ? Or is there an other solution for this problem ? Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) rebind your gridview... Regards,MhaeyPlease remember to click “Mark as Answer” on the post that helps you.. =) darkcat02: rebind your gridview...  rebinding is the process u have to do if u re manually binding to the gridview. in case ...

insert,update,delete row in gridview without saving in database
Hi  i am inserting,updating and deleting rows in a databound gridview but not saving record in database at the time of insert,update or delete butwhen i have complete all operation on gridview then there is a save button when i click this button then the gridview is saved in database.i am doing this by the help of dataset and datatable and i have stored this dataset in a session variable.this is working fine but i want to know is this a correct method.Is this may take heavy memory on server.Is there any other method for doing this.   Its depends upon the number of rows/records h...

how can I delete a row from gridview in code-behind page without using sqldatasource control?
Hi, I have image button in my gridview. and I put its command name property 'delete'. could you please tell me what code should I have in my code behind page to delete row? I don't use sqldatasource for databound I use dataset. I use VB for coding. Thanks. Something like this: Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand If (e.CommandName.Equals("delete")) Then Dim btn As ImageButton = TryCast(e.CommandSource, ImageButton) If btn IsNot Nothing...

Adding data to gridview from two textboxes and then deleting them by delete button in each gridview row.
Hi, my app has 2 textboxes if i enter data and click add button they shud be added to gridview with 2 columns ex: custid from txtbox1 ... and custname frm txtbox2 added to gridview   with columns custid and custname then    foreach row a delete button shud appear in gridview and on clicking it shud delete the row can any one send me code for dis   thanks in advance Hi, In your Button Click Event write this code. DataControlField dCusId; DataControlField dCustName; dCusId.HeaderText = textbox1.text; dCustName.HeaderText = textbox2.text Gridv...

Delete rows without moving to delete buffer
Is there any method with which we can delete rows from datawindow without moving rows to delete buffer? RowsDiscard() This will *not* remove the rows from the database. Louis Antony wrote: > Is there any method with which we can delete rows from > datawindow without moving rows to delete buffer? Thanks for the answer. But I need to remove rows from database also. > RowsDiscard() > > This will *not* remove the rows from the database. > > > > Louis Antony wrote: > > Is there any method with which we can delete rows from > > data...

Gridview Delete not Deleting
I am trying to use a command button to delete a row from a gridview. When I click the command button though, the page posts but my record is still there... no errors, just nothing seems to happen. Below is what I think is the relevant code, let me know if you need to see anything else.  I'm kinda new to working with gridview objects, it would be nice if I could see what SQL command is acctually ran... maybe there are other things I can check too, I'm just not sure how.   <asp:GridView ID="GridView1" runat="server" AllowSorting="True"&nbs...

Delete row from GridView but not database
How can I delete a row from the GridView without effecting the database?Please "Mark As Answer" if it answers your question.Software DeveloperASP.NET (C#) you can make that row "invisible" in RowDeleting event GridView1.rows[i].visible=false;  My Blog"Don't be afraid to be wrong; otherwise you'll never be right." delete the row in datasource instead. That means if you are binding it with dataset, delete the row in dataset and rebind it ....... try out this option and let me know.Thanks,Surya Prakash Jayantihttp://suryaprakashj.blogspot....

Delete a Row From A GridView Control
Well it is not just an ordinary delete. I have a Gridview which I populated manually. Then I need to delete a row which will be selected using a checkbox inside the gridview. I cant seem to find the way to just remove the specific row. I have already taken the rowIndex, but Gridview doesnt seem to allow me to delete a row unless I remove from a dataset or so. Anyhelp would be appreciated. Thanks - Mike use the property "DataKeyName" of the GridView. get the index and delete/remove the perticular row which you got through datakeyname property. and again bind your GridView. Thanx, [K...

How to delete row from GridView control
Hello,  I am working on an ASP.NET 2.0 app, and I am trying to wire up a "Delete" button to a gridview control on a form. Here is the code for the ASP :  <asp:GridView ID="gvInConditions" runat="server" AutoGenerateColumns="true" OnRowDeleting="gvInConditions_RowDeleting" DataKeyNames="Condition_ID" >         <Columns>                <asp:CommandField ButtonType="Button" SelectText=&...

Web resources about - Delete (Hide) Row from Gridview without deleting from DataBase -

GridView SelectedItem Binding Gotcha in WinRT
Last night when I was doing some WinRT hacking I was trying to setup databinding to the selected item in the GridView control and I ran into ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Advanced Search Gridview Latest News Releases All ...

CNW Group
... Services Beyond the Wire About CNW my CNW CNW Access CNW Directories Financials Webcasts Events my CNW All News Releases Advanced Search Gridview ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Add a Filter Gridview Latest News Releases All Today ...

New CmdLets of Powershell 2.0
New CmdLets of Powershell 2.0

Price Drop: Softbox
... objects- create product reflection- changing the background with something more interestingUse it as:- softbox- honeycomb softbox- gridview ...

Profile.aspx: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 25 Oct 2012 - Upcoming stories is a community based news site edited by our members. It specialises in .NET development techniques, technologies and tools including ...

View Features - ExtendASP
Call 847-681-9827 or Request a Demo View Features Testimonials Pricing About Us Coming Soon ExtendASP exposes every feature, more than any other ...

Resources last updated: 1/11/2016 1:24:09 AM