472,127 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 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 13344
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by jmdolinger | last post: by
reply views Thread by trint | last post: by
reply views Thread by Don Miller | last post: by
4 posts views Thread by Don Miller | last post: by
reply views Thread by Sobin Thomas | last post: by
1 post views Thread by Sobin Thomas | last post: by
3 posts views Thread by Peter | last post: by
reply views Thread by leo001 | last post: by

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.