473,793 Members | 2,927 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deleting rows from an unbound gridview

I have a gridview on my form which I have populated using a
datareader. What I would like to do is to be able to remove specified
records from the gridview, without affecting the source of the data.

I'm a bit confused about how to go about removing the rows - all the
google searches I have done so far seem to assume that the grid view
is bound and the programmer wants to delete the data from the original
source. Is there any easy way to do this - i.e. delete row x from the
grid?

I'd be grateful for any help with this!

Greg.

Feb 1 '07 #1
11 2564
"Greg" <sp**********@y ahoo.co.ukwrote in message
news:11******** **************@ a75g2000cwd.goo glegroups.com.. .
>I have a gridview on my form which I have populated using a
datareader. What I would like to do is to be able to remove specified
records from the gridview, without affecting the source of the data.
Do you mean you want to remove the rows client-side once the page has
actually been rendered, or do you want to prevent certain rows from being
rendered to the page as the data is being bound...?
Feb 1 '07 #2
On 1 Feb, 19:19, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
"Greg" <spammesil...@y ahoo.co.ukwrote in message

news:11******** **************@ a75g2000cwd.goo glegroups.com.. .
I have a gridview on my form which I have populated using a
datareader. What I would like to do is to be able to remove specified
records from the gridview, without affecting the source of the data.

Do you mean you want to remove the rows client-side once the page has
actually been rendered, or do you want to prevent certain rows from being
rendered to the page as the data is being bound...?
The latter, I suppose, but what I was hoping to do was to actually
remove the rows from the server side grid view object, not just refuse
to render those rows.

Thanks,

Greg.

Feb 1 '07 #3
"Greg" <sp**********@y ahoo.co.ukwrote in message
news:11******** **************@ v33g2000cwv.goo glegroups.com.. .
but what I was hoping to do was to actually remove the rows from the
server side grid view object, not just refuse to render those rows.
What's the difference...?
Feb 1 '07 #4
On 1 Feb, 19:34, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
"Greg" <spammesil...@y ahoo.co.ukwrote in message

news:11******** **************@ v33g2000cwv.goo glegroups.com.. .
but what I was hoping to do was to actually remove the rows from the
server side grid view object, not just refuse to render those rows.

What's the difference...?
Visually nothing, but if I later want to refer to the server side
gridview object, I don't want to have to remember which rows have been
hidden from the the user.

Unless of course I misunderstood you.... I'm a complete beginner at
web development (I normally do win forms stuff).

Thanks.

Greg.

Feb 1 '07 #5
Greg,

As you have discovered, the GridView control does not allow you to
manipulate rows (unless you put them in the footer or something like
that). What you want to do is create the datasource (ObjectDataSour ce,
DataSet, etc) programatically where you can manipulate and filter its
contents. I prefer to put this logic in a separate class, but you
could put it in your code-behind class.

Then you bind the customized datasource to the gridview:
grdUsers.DataSo urce = myDataSource;
grdUsers.DataBi nd();

Best wishes,
Wesley
>
but what I was hoping to do was to actually remove the rows from the
server side grid view object, not just refuse to render those rows.
What's the difference...?

Visually nothing, but if I later want to refer to the server side
gridview object, I don't want to have to remember which rows have been
hidden from the the user.

Unless of course I misunderstood you.... I'm a complete beginner at
web development (I normally do win forms stuff).

Thanks.

Greg.

Feb 1 '07 #6
"Greg" <sp**********@y ahoo.co.ukwrote in message
news:11******** **************@ p10g2000cwp.goo glegroups.com.. .
Visually nothing, but if I later want to refer to the server side
gridview object, I don't want to have to remember which rows have been
hidden from the the user.
Aha...!

Sounds like what you want to do is fetch your underlying data into a
DataSet, create a "view" of that data which you can filter, then bind the
GridView to the filtered view instead of the underlying DataSet, which
remains intact...

using (DataSet MyDataSet = <whatever method you have for creating DataSets)
{
MyDataSet.Table s[0].DefaultView.Ro wFilter = "FirstName = 'Greg'";
MyGridView.Data Source = MyDataSet.Table s[0].DefaultView;
MyGridView.Data Bind();
}
Feb 1 '07 #7
On 1 Feb, 20:26, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
"Greg" <spammesil...@y ahoo.co.ukwrote in message

news:11******** **************@ p10g2000cwp.goo glegroups.com.. .
Visually nothing, but if I later want to refer to the server side
gridview object, I don't want to have to remember which rows have been
hidden from the the user.

Aha...!

Sounds like what you want to do is fetch your underlying data into a
DataSet, create a "view" of that data which you can filter, then bind the
GridView to the filtered view instead of the underlying DataSet, which
remains intact...

using (DataSet MyDataSet = <whatever method you have for creating DataSets)
{
MyDataSet.Table s[0].DefaultView.Ro wFilter = "FirstName = 'Greg'";
MyGridView.Data Source = MyDataSet.Table s[0].DefaultView;
MyGridView.Data Bind();

}
Thanks a lot Wesley and Mark - I'm getting very close now to where I
need to be!

I think the best way to achieve what I want may be to create a
temporary table in the database with the user's edited copy of what
was originally extracted from the table that can't be edited. They
could then edit the contents of the temporary table to their hearts
content, and then when happy, update another table using the contents
of the temporary table. That way I don't have to worry too much about
state. Does that sound like a plan, or over complicating things?

Thanks again,

Greg.

Feb 2 '07 #8
"Greg" <sp**********@y ahoo.co.ukwrote in message
news:11******** *************@v 33g2000cwv.goog legroups.com...
I think the best way to achieve what I want may be to create a
temporary table in the database with the user's edited copy of what
was originally extracted from the table that can't be edited. They
could then edit the contents of the temporary table to their hearts
content, and then when happy, update another table using the contents
of the temporary table. That way I don't have to worry too much about
state. Does that sound like a plan, or over complicating things?
It's a little difficult to tell as you don't mention why any of this is
necessary...
Feb 2 '07 #9
On 2 Feb, 11:20, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
"Greg" <spammesil...@y ahoo.co.ukwrote in message

news:11******** *************@v 33g2000cwv.goog legroups.com...
I think the best way to achieve what I want may be to create a
temporary table in the database with the user's edited copy of what
was originally extracted from the table that can't be edited. They
could then edit the contents of the temporary table to their hearts
content, and then when happy, update another table using the contents
of the temporary table. That way I don't have to worry too much about
state. Does that sound like a plan, or over complicating things?

It's a little difficult to tell as you don't mention why any of this is
necessary...
Mark,

Yes, I can see why you're not too clear on what I am trying to do. The
requirements can be summarised thus:(NB there is a lot, lot more going
on in the form besides this, but nothing else is relevant)

There are 2 relevant tables in the database, lets call them
masterSchedule and actualSchedule.

When the user clicks on a button, a grid is shown with the contents of
the masterSchedule table. The user can then add to these details or
remove individual details. On pressing a button, the displayed
contents are inserted into the actualSchedule table. The
masterSchedule table is therefore acting as a group of suggestions, or
a template, as to what will eventually be sent to the actualSchedule
table. The masterSchedule table can never be edited by my part of the
application.

Thanks a lot for your time, and I apologise if I didn't explain fully
enough earlier on in the thread!

Greg.


Feb 2 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1245
by: Wannabe | last post by:
I have been trying to figure this out for days now...can someone please help? I am using ASP.Net 2.0 and have a gridview on my page. I have everything working except the delete command. The page reloads except the row I am trying to delete is still there. I believe it is something really easy, but I cannot see it. The stored procedue works when run in QA. Can someone tell me what I am doing wrong/missing that is keeping the delete...
1
1455
by: =?Utf-8?B?QW1pdA==?= | last post by:
I have an object datasource control that is referencing a class in the app code directory called SQLCommands.vb. That class calls stored procs in a remote server. On my page I'm using a GridView to update fields. I click edit, and edit some info, then click update and it calls the right update function. It executes the query with no exceptions and when the page refreshes the row disappears! Anyone experience anything like this? ...
2
5461
by: Greg | last post by:
I have a gridview on my form which I have populated using a datareader. What I would like to do is to be able to remove specified records from the gridview, without affecting the source of the data. I'm a bit confused about how to go about removing the rows - all the google searches I have done so far seem to assume that the grid view is bound and the programmer wants to delete the data from the original source. Is there any easy way to...
1
2706
by: Greg | last post by:
I have a gridview on my form which I have populated using a datareader. What I would like to do is to be able to remove specified records from the gridview, without affecting the source of the data. I'm a bit confused about how to go about removing the rows - all the google searches I have done so far seem to assume that the grid view is bound and the programmer wants to delete the data from the original source. Is there any easy way to...
2
2117
by: Blasting Cap | last post by:
I've got a gridview (that I converted over from a datagrid, which had been working properly), that is doubling up the number of rows returned. When it was running as a datagrid, the same code sent back the proper number of rows. The only thing different I am doing is to display the number of rows returned in the footer of the gridview. The Bindgrid is as follows: Sub BindGrid() Session("reportlevel") = Session("availabilityrptlevel")
2
1558
by: mathewgk80 | last post by:
Hi all, when i try to delete the last row from gridview, i got an exception "Array index out of bound.. When i try to delete some other row, all the rows that follow that row is deleted.. For example, If i have 10 rows in a grid view and when i try to delete the 10th row, it throws an exception..
1
3036
by: bJames | last post by:
Hi I've been all around looking for an answer to this question, but can't find it. I've got a gridview with a single unbound column. It's got a textbox and button in the footer row. I"m trying to get the value from the textbox to add to the gridview on the button click. After trying to integrate other solutions into my code I've come up with this garbled mess in the button click event: DataTable paramValues = new DataTable(); ...
0
2381
by: Andy B | last post by:
I have the following gridview. There are 2 other textBoxes and a button on the page as well. When somebody puts text into the 2 textBoxes and presses the add button, it puts the values of those textBoxes into the DataTable. The gridView shows what values have already been entered into the DataTable. <asp:GridView ID="DefinitionList" runat="server" Caption="Dictionary entries" EmptyDataText="There are no definitions yet." AllowPaging="True"...
1
1848
by: COHENMARVIN | last post by:
I have a gridview and I need to know the number of rows in it. I find the Page_load and the Gridview_Load events are too early to find out the number of rows. I can use the Gridview_databound event to check for the number of rows. But the problem is that the user can update a field on my form, which reduces the number of rows in the gridview, because the gridview SELECT statement no longer finds the records when their flag has been set...
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10159
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9033
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.