I was just wondering if it's possible to cast a datagrid DataSource as a
DataSet?
I've stepped through my code when the grid is first being bound and the
DataSource shows up as a DataSet for the datagrid. Then, when I handle on
OnClick event for an image button and the page posts back, I look at the
DataSource for the grid and it says it's null. Is there any way of getting
the grid's current datasource after it loads?
I've tried this exact snipit of code:
DataSet ds = (DataSet)dgResu lts.DataSource; ....but this is where it says
the DataSource is null.
I want to be able to pull the datasource into a dataset, add a new row to
the dataset and rebind the datagrid showing a new blank row in the grid.
Any help would be appreciated.
--
Thanks in advance,
John Scott. 1 1490
"John Scott" wrote: I was just wondering if it's possible to cast a datagrid DataSource as a DataSet?
I've stepped through my code when the grid is first being bound and the DataSource shows up as a DataSet for the datagrid. Then, when I handle on OnClick event for an image button and the page posts back, I look at the DataSource for the grid and it says it's null. Is there any way of getting the grid's current datasource after it loads?
I've tried this exact snipit of code: DataSet ds = (DataSet)dgResu lts.DataSource; ....but this is where it says the DataSource is null.
I want to be able to pull the datasource into a dataset, add a new row to the dataset and rebind the datagrid showing a new blank row in the grid.
what happens is that the dataset is "forgotten" on each postback.
The only reason why you see data at all in the grid is because of the
viewstate preserving it. The viewstate only preserves the data though, not
where its coming from. so you go from having the data in a dataset (relations
etc) to having just the raw data in a table.
The "cure" would be to store the dataset on the session by using
Session["somekey"] = myDataSet;
for example at the end of the pageload ( if(!IsPostBack) )
then retrieving it when you need it
(if( myDataSet == null ) { myDataSet = Session["somekey"] as DataSet; }
after doing this you are left with your original dataset. modify it and do a
databind again and you should be set
mvh
Andreas This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: PuckInLA |
last post by:
I have a question. I have some data that I am pulling into a dataset
that needs to have each row of data emailed out. I got the email
funciton working great but its extracting that data that is becoming
the problem. I assume it would be in a loop, and to do that I am
guessing something like this:
for each item in dataset
extact row
email rowinfo
for next
|
by: ar |
last post by:
Hi,
I have a page where I have a dataset with a single table (table1) with a
single column (col1). I am very simply trying to add items to the dataset
one at a time, and rebind the dataset to a datagrid after adding each item. I
guess my question is ...does a dataset/datatable not hold a value after a
postback? Or maybe my code is just wrong....but my datagrid doesn't add
additional items like I want it to when I click Button1. My...
|
by: Frosty |
last post by:
Hi
I am using the VS xsd designer to create a strongly typed dataset. The dataset is apparently successfully created, with no warnings or errors given. Is it not then to be expected that this dataset then should reflect all the details put into the xsd? Somewhere down the line there is not a 1:1 relationship. Be it that .NET is so tightly coupled to xsd, xml and dataset I would have expected any discrepancies to have been well documented and...
|
by: Diego TERCERO |
last post by:
Hi...
I'm working on a tool for editing text resources for a family of software
product my company produces.
These text resources are found in a SQL Server database, in a table called
"Resource" with the following structure :
Resource{,en,fr,es}
Yes.. these are the only languages supported actually.
A couple of rows in that table would look like this :
|
by: washoetech |
last post by:
Hello,
I am working on a project where I need to be able to grab the data from an
Excel spreadsheet and create a new table in my database based on the columns
in the spreadsheet. After the table is created then I need to fill the table
with the data from that spreadsheet. I am using ASP.NET 2.0 and SQL 2000 for
my database.
What would be the best way to do this? Should I go Excel to XML or Excel to
a Dataset?
| |
by: Datatable Dataset Datagrid help |
last post by:
Hi I am somewhat confused, I am new at VB.net
I use XML data,
I have a datagrid,
I created a datatable so that I can create a custom format like true is this
graphic false is this graphic and others.
One of the custom format is as follows:
dsmessages_dt.Columns.Add("Image", GetType(Image))
I had a problem of when I used a checkbox in the grid that was bound to the
datatable that it would not update my dataset. So I created another...
|
by: A_PK |
last post by:
I have problem databinding the DataGrid with DataView/DataSet after the
filter...
I create the following proceudre in order for user to filter as many as they
want, but the following code is only allow user to filter the first time,
when they tried the second time, the speficied cast error message will
prompt one....
I create a mydataset1 first, and the mydataset1 data source was getting from
DataGrid.DataSource.
|
by: John Scott |
last post by:
I was just wondering if it's possible to cast a datagrid DataSource as a
DataSet?
I've stepped through my code when the grid is first being bound and the
DataSource shows up as a DataSet for the datagrid. Then, when I handle on
OnClick event for an image button and the page posts back, I look at the
DataSource for the grid and it says it's null. Is there any way of getting
the grid's current datasource after it loads?
I've tried...
|
by: Jerms |
last post by:
Hello all,
I've been using this site quite a bit since starting my project and have found it very helpful. I have run into a roadblock though that I cant seem to scrounge up a solution to.
I have this dataset created (REACHpointsdataset) with a few tables in it (points, users, items, etc.), I also add another table to this database though code which I pull from a webservice. Two of the tables are of interest to me right now are empl (from...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |