473,394 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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.DataSource 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 13466
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**********************************@microsof t.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.DataSource 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.EditIndex = xxx;
GridView1.DataSource = xxxx;
GridView1.DataBind();

}

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: AcYNpsl0Syq2RrBcREe6wfYfjulJUQ==
| 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**********************************@microsoft.co m>
| 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.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:367833
| X-Tomcat-NG: microsoft.public.dotnet.framework.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.DataSource 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
ObjectDataSource, 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.EditIndex = xxx;
GridView1.DataSource = xxxx;
GridView1.DataBind();

}

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: AcYNpsl0Syq2RrBcREe6wfYfjulJUQ==
| 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**********************************@microsoft.co m>
| 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.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:367833
| X-Tomcat-NG: microsoft.public.dotnet.framework.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.DataSource 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(gridview, detailsview.....), you're wantting to use
some datasource from other source or storage, like sessionstate, cache or
....., am I misunderstanding?

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.EditIndex =e.Item.ItemIndex;
GridView1.DataSource = GetDataSourceFromSession();
GridView1.DataBind();

}

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 DataSourcecontrol'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+TFymxsBotXlOTQ==
| X-WBNR-Posting-Host: 4.36.209.2
| From: "=?Utf-8?B?SmltIEthdHo=?=" <Za*****@nospam.nospam>
| References: <66**********************************@microsoft.co m>
<0w**************@TK2MSFTNGXA02.phx.gbl>
| Subject: RE: GridView without DataSource
| Date: Tue, 3 Jan 2006 07:58:03 -0800
| Lines: 95
| Message-ID: <45**********************************@microsoft.co m>
| 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.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:368287
| X-Tomcat-NG: microsoft.public.dotnet.framework.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
| ObjectDataSource, 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.EditIndex = xxx;
| > GridView1.DataSource = xxxx;
| > GridView1.DataBind();
| >
| > }
| >
| > 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: AcYNpsl0Syq2RrBcREe6wfYfjulJUQ==
| > | 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**********************************@microsoft.co m>
| > | 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.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:367833
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.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.DataSource 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
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...
1
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...
0
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...
0
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...
4
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...
4
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...
0
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...
1
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...
3
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...

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.