Page_Load
datagrid1.datas ource=dataset1
//I am filling the datagrid and it works fine when page is displayed
end
---------------
button 1_click
dim ds as dataset
ds=datagrid1.da tasource
//gives error
end
when I try to get the datasource from a datagrid (i.e. a dataset) it gives
error
"Object reference not set to an instance of an object."
is it due to postback event the datagrid's datasource is not accessible ??
vips 6 1966
try casting
Not sure of the the VB code but in C#
DataSet ds = new DataSet();
ds = (dataset)datagr id1.datasource;
"vips" <yp**@hotmail.c om> wrote in message
news:OZ******** ******@TK2MSFTN GP14.phx.gbl... Page_Load
datagrid1.datas ource=dataset1
//I am filling the datagrid and it works fine when page is displayed
end
---------------
button 1_click
dim ds as dataset
ds=datagrid1.da tasource
//gives error
end when I try to get the datasource from a datagrid (i.e. a dataset) it gives error
"Object reference not set to an instance of an object."
is it due to postback event the datagrid's datasource is not accessible ?? vips
That's right. The datasource isn't maintained in viewstate as a raw
dataset..instea d only the information necessary to the datagrid (rows,
columns, ...) are maintained. If you need the dataset again you'll need
to either recreate it or store it somewhere...
KArl
--
MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"vips" <yp**@hotmail.c om> wrote in message
news:OZ******** ******@TK2MSFTN GP14.phx.gbl... Page_Load
datagrid1.datas ource=dataset1
//I am filling the datagrid and it works fine when page is displayed
end
---------------
button 1_click
dim ds as dataset
ds=datagrid1.da tasource
//gives error
end when I try to get the datasource from a datagrid (i.e. a dataset) it gives error
"Object reference not set to an instance of an object."
is it due to postback event the datagrid's datasource is not accessible ?? vips
it'd be ctype(DataGrid1 .DataSource, DataSet) but if that was the error I
wouldn't expect him to get a nullreference error...instead I'd expect him to
get an invalid cast...
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Grant Merwitz" <gr***@workshar e.com> wrote in message
news:uO******** ******@TK2MSFTN GP09.phx.gbl... try casting
Not sure of the the VB code but in C#
DataSet ds = new DataSet(); ds = (dataset)datagr id1.datasource;
"vips" <yp**@hotmail.c om> wrote in message news:OZ******** ******@TK2MSFTN GP14.phx.gbl... Page_Load
datagrid1.datas ource=dataset1
//I am filling the datagrid and it works fine when page is displayed
end
---------------
button 1_click
dim ds as dataset
ds=datagrid1.da tasource
//gives error
end when I try to get the datasource from a datagrid (i.e. a dataset) it gives error
"Object reference not set to an instance of an object."
is it due to postback event the datagrid's datasource is not accessible ?? vips
I am getting datagrid.dataso urce as nothing !!
"Grant Merwitz" <gr***@workshar e.com> wrote in message
news:uO******** ******@TK2MSFTN GP09.phx.gbl... try casting
Not sure of the the VB code but in C#
DataSet ds = new DataSet(); ds = (dataset)datagr id1.datasource;
"vips" <yp**@hotmail.c om> wrote in message news:OZ******** ******@TK2MSFTN GP14.phx.gbl... Page_Load
datagrid1.datas ource=dataset1
//I am filling the datagrid and it works fine when page is displayed
end
---------------
button 1_click
dim ds as dataset
ds=datagrid1.da tasource
//gives error
end when I try to get the datasource from a datagrid (i.e. a dataset) it
gives error
"Object reference not set to an instance of an object."
is it due to postback event the datagrid's datasource is not accessible
??
vips
u mean I need to keep the dataset it in viewstate ??
but the framework itself keeps it in viewstate ...cant i access it some how
??
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:u1******** ********@TK2MSF TNGP14.phx.gbl. .. That's right. The datasource isn't maintained in viewstate as a raw dataset..instea d only the information necessary to the datagrid (rows, columns, ...) are maintained. If you need the dataset again you'll need to either recreate it or store it somewhere...
KArl
-- MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to come!) "vips" <yp**@hotmail.c om> wrote in message news:OZ******** ******@TK2MSFTN GP14.phx.gbl... Page_Load
datagrid1.datas ource=dataset1
//I am filling the datagrid and it works fine when page is displayed
end
---------------
button 1_click
dim ds as dataset
ds=datagrid1.da tasource
//gives error
end when I try to get the datasource from a datagrid (i.e. a dataset) it
gives error
"Object reference not set to an instance of an object."
is it due to postback event the datagrid's datasource is not accessible
??
vips
I mean, you can keep it wherever you want...viewstat e, session,
cache..whatever appropriate for your situation (don't know enough to tell
you).
The framework doesn't keep the dataset in the viewstate. It keeps the
controls which make up the datagrid (which were build using the dataset) but
not the dataset itself...
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"vips" <yp**@hotmail.c om> wrote in message
news:OG******** ******@TK2MSFTN GP09.phx.gbl... u mean I need to keep the dataset it in viewstate ?? but the framework itself keeps it in viewstate ...cant i access it some how ??
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:u1******** ********@TK2MSF TNGP14.phx.gbl. .. That's right. The datasource isn't maintained in viewstate as a raw dataset..instea d only the information necessary to the datagrid (rows, columns, ...) are maintained. If you need the dataset again you'll need to either recreate it or store it somewhere...
KArl
-- MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to come!) "vips" <yp**@hotmail.c om> wrote in message news:OZ******** ******@TK2MSFTN GP14.phx.gbl... > Page_Load > > datagrid1.datas ource=dataset1 > > //I am filling the datagrid and it works fine when page is displayed > > end > > --------------- > > button 1_click > > dim ds as dataset > > ds=datagrid1.da tasource > > //gives error > > end > > > > when I try to get the datasource from a datagrid (i.e. a dataset) it gives > error > > "Object reference not set to an instance of an object." > > is it due to postback event the datagrid's datasource is not accessible ?? > > > > vips > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: DraguVaso |
last post by:
Hi,
I need a function that gives me the number of Columns shown in a DataGrid.
So I don't need to know the number of columns shown in tha DataSource,
because this number can be completely something else than the number of
columns defined in the currently active TableStyle!
I currently use DataGrid.TableStyles(0).GridColumnStyles.Count, but i know
this won't work when using more than one TableStyle, or having a TableStyle
with another...
|
by: pei_world |
last post by:
I want to implement a key hit with enter to dropdown a combobox that is in
the datagrid. in this case I need to override its original behaviours. I
found some codes from the web. Does anyone know how to use this code? please
help!
http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20862953.html
|
by: Brett |
last post by:
I have the following code in VS Studio .NET 2005 beta:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.DataAdapter1.Fill(DataSet1)
End Sub
Where a database connection has been made during design time and I can
preview data. The above line gives a "specified method is not supported
|
by: rupalirane07 |
last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error:
NullReferenceException error
Any help........pls urgent
=========================================================
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm3.aspx.vb" Inherits="TestDatagrids.WebForm3"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">...
|
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: 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: 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...
|
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();...
| |
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |