473,721 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView without DataSource

I have an application that updates a strongly typed data set at run time.
I'd like to dynamically create a table that connects to a run time data
table. For displaying the data, this works well. I just set the
GridView.DataSo urce once, and call DataBind();

I'd like to drive the application from the GridView control, by including
command buttons that allow editing of the data. Starting out simple, I
have a DataTable with a boolean "use" field (read-write) and a number field
(read-only).

I'd like to have an Edit button allow me to toggle the boolean checkbox
(which will be bound to the "use" field

Now, this data is not connected to a DataSource, so I'd like to know what I
have to do in the GridView's RowEditing event handler to make the GridView's
selected row editable.

JoBeetz
--
Senior Developer
Transform Pharmaceuticals
Dec 31 '05 #1
4 13489
Jo / Jim,

I think you will have a pretty difficult time using a GridView without a
data source. The control just isn't designed to work without some type of a
store.

-A

--

Andrew Robinson
www.binaryocean.com
www.bellinghamdotnet.org
"Jim Katz" <Za*****@nospam .nospam> wrote in message
news:66******** *************** ***********@mic rosoft.com...
I have an application that updates a strongly typed data set at run time.
I'd like to dynamically create a table that connects to a run time data
table. For displaying the data, this works well. I just set the
GridView.DataSo urce once, and call DataBind();

I'd like to drive the application from the GridView control, by including
command buttons that allow editing of the data. Starting out simple, I
have a DataTable with a boolean "use" field (read-write) and a number
field
(read-only).

I'd like to have an Edit button allow me to toggle the boolean checkbox
(which will be bound to the "use" field

Now, this data is not connected to a DataSource, so I'd like to know what
I
have to do in the GridView's RowEditing event handler to make the
GridView's
selected row editable.

JoBeetz
--
Senior Developer
Transform Pharmaceuticals

Dec 31 '05 #2
Hi JoBeetz,

As Andrew has mentioned, the ASP.NET GridView or other template databound
control (DataGrid, DataList....) are based on datasource to populate Items.
So when we need to performing edit or updating in those control, we need to
set the EditIndex and the redo the databinding with a certain DataSource.
e.g:

Button_Click(.. ...)
{
GridView1.EditI ndex = xxx;
GridView1.DataS ource = xxxx;
GridView1.DataB ind();

}

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Thread-Topic: GridView without DataSource
| thread-index: AcYNpsl0Syq2RrB cREe6wfYfjulJUQ ==
| X-WBNR-Posting-Host: 4.36.209.2
| From: "=?Utf-8?B?SmltIEthdHo =?=" <Za*****@nospam .nospam>
| Subject: GridView without DataSource
| Date: Fri, 30 Dec 2005 17:09:02 -0800
| Lines: 21
| Message-ID: <66************ *************** *******@microso ft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.p hx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGXA03.phx .gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3678 33
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| I have an application that updates a strongly typed data set at run time.

| I'd like to dynamically create a table that connects to a run time data
| table. For displaying the data, this works well. I just set the
| GridView.DataSo urce once, and call DataBind();
|
| I'd like to drive the application from the GridView control, by including
| command buttons that allow editing of the data. Starting out simple, I
| have a DataTable with a boolean "use" field (read-write) and a number
field
| (read-only).
|
| I'd like to have an Edit button allow me to toggle the boolean checkbox
| (which will be bound to the "use" field
|
| Now, this data is not connected to a DataSource, so I'd like to know what
I
| have to do in the GridView's RowEditing event handler to make the
GridView's
| selected row editable.
|
| JoBeetz
| --
| Senior Developer
| Transform Pharmaceuticals
|

Jan 3 '06 #3
Heh heh. That's exactly what I do in response to a button in the data grid.

I think my biggest problem with this is mostly that, to use an
ObjectDataSourc e, the objectdata source has to get its data completely out of
the context of the page. This makes a dynamic gridview, which can'tbe
constructed until some aspect of the page is derived, a real pain. If you
use a detached class as the object source, I need that class to have access
to the session contents to deliver session specific data.

How can I do this? Thanks,
--
Senior Developer
Transform Pharmaceuticals
"Steven Cheng[MSFT]" wrote:
Hi JoBeetz,

As Andrew has mentioned, the ASP.NET GridView or other template databound
control (DataGrid, DataList....) are based on datasource to populate Items.
So when we need to performing edit or updating in those control, we need to
set the EditIndex and the redo the databinding with a certain DataSource.
e.g:

Button_Click(.. ...)
{
GridView1.EditI ndex = xxx;
GridView1.DataS ource = xxxx;
GridView1.DataB ind();

}

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Thread-Topic: GridView without DataSource
| thread-index: AcYNpsl0Syq2RrB cREe6wfYfjulJUQ ==
| X-WBNR-Posting-Host: 4.36.209.2
| From: "=?Utf-8?B?SmltIEthdHo =?=" <Za*****@nospam .nospam>
| Subject: GridView without DataSource
| Date: Fri, 30 Dec 2005 17:09:02 -0800
| Lines: 21
| Message-ID: <66************ *************** *******@microso ft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.p hx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGXA03.phx .gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3678 33
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| I have an application that updates a strongly typed data set at run time.

| I'd like to dynamically create a table that connects to a run time data
| table. For displaying the data, this works well. I just set the
| GridView.DataSo urce once, and call DataBind();
|
| I'd like to drive the application from the GridView control, by including
| command buttons that allow editing of the data. Starting out simple, I
| have a DataTable with a boolean "use" field (read-write) and a number
field
| (read-only).
|
| I'd like to have an Edit button allow me to toggle the boolean checkbox
| (which will be bound to the "use" field
|
| Now, this data is not connected to a DataSource, so I'd like to know what
I
| have to do in the GridView's RowEditing event handler to make the
GridView's
| selected row editable.
|
| JoBeetz
| --
| Senior Developer
| Transform Pharmaceuticals
|

Jan 3 '06 #4
Thanks for your response JoBeetz,

En, not sure whether I've completely got your point. What I think currently
is that you want to get rid of the DataSource control which rely on the
page's lifecycle and automatically retrieve data and do the databinding on
those databound control(gridvie w, detailsview.... .), you're wantting to use
some datasource from other source or storage, like sessionstate, cache or
....., am I misunderstandin g?

If this is what you want , I think that's quite simple since we can still
using the ASP.NET 1.1 databinding style, set the Databound control's
DataSource to any datasource Object(not necessarily a datasource
control....) and call the databind() method....

Just as I've mentioned in previous message,

ItemCommand ( object sender, xxxeventArgs e)
{
GridView1.EditI ndex =e.Item.ItemInd ex;
GridView1.DataS ource = GetDataSourceFr omSession();
GridView1.DataB ind();

}

this still work well. Also, if the GridView or other databound control
is dynamically created (you should create and add them into page in Page's
Init or Load event....), we can also use such means or just assign an
existing DataSourcecontr ol's ID to its DataSourceID property to perform
databinding.... .

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: GridView without DataSource
| thread-index: AcYQfnqKXGY0/4f+TFymxsBotXlO TQ==
| X-WBNR-Posting-Host: 4.36.209.2
| From: "=?Utf-8?B?SmltIEthdHo =?=" <Za*****@nospam .nospam>
| References: <66************ *************** *******@microso ft.com>
<0w************ **@TK2MSFTNGXA0 2.phx.gbl>
| Subject: RE: GridView without DataSource
| Date: Tue, 3 Jan 2006 07:58:03 -0800
| Lines: 95
| Message-ID: <45************ *************** *******@microso ft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.p hx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GXA03.phx.gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3682 87
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Heh heh. That's exactly what I do in response to a button in the data
grid.
|
| I think my biggest problem with this is mostly that, to use an
| ObjectDataSourc e, the objectdata source has to get its data completely
out of
| the context of the page. This makes a dynamic gridview, which can'tbe
| constructed until some aspect of the page is derived, a real pain. If
you
| use a detached class as the object source, I need that class to have
access
| to the session contents to deliver session specific data.
|
| How can I do this? Thanks,
| --
| Senior Developer
| Transform Pharmaceuticals
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi JoBeetz,
| >
| > As Andrew has mentioned, the ASP.NET GridView or other template
databound
| > control (DataGrid, DataList....) are based on datasource to populate
Items.
| > So when we need to performing edit or updating in those control, we
need to
| > set the EditIndex and the redo the databinding with a certain
DataSource.
| > e.g:
| >
| > Button_Click(.. ...)
| > {
| > GridView1.EditI ndex = xxx;
| > GridView1.DataS ource = xxxx;
| > GridView1.DataB ind();
| >
| > }
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| > --------------------
| > | Thread-Topic: GridView without DataSource
| > | thread-index: AcYNpsl0Syq2RrB cREe6wfYfjulJUQ ==
| > | X-WBNR-Posting-Host: 4.36.209.2
| > | From: "=?Utf-8?B?SmltIEthdHo =?=" <Za*****@nospam .nospam>
| > | Subject: GridView without DataSource
| > | Date: Fri, 30 Dec 2005 17:09:02 -0800
| > | Lines: 21
| > | Message-ID: <66************ *************** *******@microso ft.com>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| > | NNTP-Posting-Host: TK2MSFTNGXA03.p hx.gbl 10.40.2.250
| > | Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGXA03.phx .gbl
| > | Xref: TK2MSFTNGXA02.p hx.gbl
| > microsoft.publi c.dotnet.framew ork.aspnet:3678 33
| > | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| > |
| > | I have an application that updates a strongly typed data set at run
time.
| >
| > | I'd like to dynamically create a table that connects to a run time
data
| > | table. For displaying the data, this works well. I just set the
| > | GridView.DataSo urce once, and call DataBind();
| > |
| > | I'd like to drive the application from the GridView control, by
including
| > | command buttons that allow editing of the data. Starting out
simple, I
| > | have a DataTable with a boolean "use" field (read-write) and a number
| > field
| > | (read-only).
| > |
| > | I'd like to have an Edit button allow me to toggle the boolean
checkbox
| > | (which will be bound to the "use" field
| > |
| > | Now, this data is not connected to a DataSource, so I'd like to know
what
| > I
| > | have to do in the GridView's RowEditing event handler to make the
| > GridView's
| > | selected row editable.
| > |
| > | JoBeetz
| > | --
| > | Senior Developer
| > | Transform Pharmaceuticals
| > |
| >
| >
|

Jan 4 '06 #5

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

Similar topics

7
14810
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I want to look at that data and filter it based on what is in it. I know that this could have been done with data sets and data views in asp.net 1.1 but how is this done now in asp.net 2.0?
1
3528
by: jmdolinger | last post by:
Hi all, I'm a newbie to Atlas (and recently ASP.NET) after coming from a long Java background, also have done quite a bit with an Ajax.NET/ASP.NET 1.1 project, but it was basically all javascript, nothing really having to do with ASP.NET... I'm attempting to put together an application that consists of several GridView controls each bound to some xml data. Each table exists in its own update panel. The two effects I'm going for are:
0
1519
by: trint | last post by:
I hope I can explain this clearly enough to get help. I have three gridviews that need to work from each other to display like a java verticle menu (just in the way it appears). GridView1 is fine with this code: <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="id" autogenerateselectbutton="True" autogeneratecolumns="False"
0
2004
by: Don Miller | last post by:
Here is an example of what I believe is a bug in ASP.NET 2.0 GridView paging without postbacks (or at least not documented how to fix it). Once the GridView is displayed, clicking on any of the paging tools causes the GridView to completely disappear! This happens when either DataSets or DataTables are used (it doesn't work at all for DataReaders because they don't support paging apparently). If you remove the...
4
2724
by: Don Miller | last post by:
This is a repost of a reproducible problem/bug with GridView with dynamic SQL and binding. Is there a better ASP.NET newsgroup I should post to where MS techs or MVPs take an interest in such problems? Thanks. Here is an example of what I believe is a bug in ASP.NET 2.0 GridView paging without postbacks (or at least not documented how to fix it). Once the GridView is displayed, clicking on any of the paging tools causes the
4
9790
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This sounds easy but the next requirement is that the GridView is editable. So I have included the SelectCommand and the UpdateCommand on the SqlDataSource to allow the GridView to be editable. I have now been able to get the GridView to display data...
0
1529
by: Sobin Thomas | last post by:
Hi All, How can I bind the Gridview control to Sql Datasource control on a button click(I see majority of the articles binding datasource at page load) I need to enable the paging and sorting of the Gridview control also .Actually I am able to bind the sql datasource control to the Gridview on button Click but on clicking the GridView for paging or sorting , the Gridview vanishes!! In short, I want to bind the GridView control to a...
1
2021
by: Sobin Thomas | last post by:
Hi All, How can I bind the Gridview control to Sql Datasource control on a button click(I see majority of the articles binding datasource at page load) I need to enable the paging and sorting of the Gridview control also .Actually I am able to bind the sql datasource control to the Gridview on button Click but on clicking the GridView for paging or sorting , the Gridview vanishes!! In short, I want to bind the GridView control to a...
3
5242
by: Peter | last post by:
I have a GridView which is populated by List<ofObjects> Does anyone have example of how to sort the columns of this GridView? I have found examples without DataSourceControl but these use DataTable, I am using List of Objects. Here's one example: http://ryanolshan.com/technology/gridview-without-datasourcecontrol-datasource/
0
8728
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
9366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9130
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
9059
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
8005
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...
1
6668
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5979
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
4484
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...
0
4751
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.