Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

ASP.NET and DataSets

I have a Classic ASP application that uses an MS SQL Server database.  I am going to migrate the ASP app to ASP.NET and make some enhancements.  I will be making some changes to the database tables for this enhancement.  

I created a new DataSet and added datatables manually to the DataSet to represent the changes I will be making for the enhancement.  (I can't change the database yet and don't want to wait to begin my development.)

What I need to do now is add a GridView to my form using data from a table in my newly created DataSet.  When I choose Object as my DataSource Type, it doesn't allow me to choose my new DataSet even though it exists in my App_Code folder.

My plan is to populate the new DataSet during the PageLoad Event as a temporary measure until I can make the database changes.

I am using VS 2010.  Any help would be greatly appreciated!
0
dyarosh
Asked:
dyarosh
1 Solution
 
teebonCommented:
Can you post the detailed error message for the DataSet issue you facing?
0
 
sarabhaiCommented:
if you use database store procedure with dump/temporary data to return it will work
for e.g. if u use store procedure like usp_user
create proc usp_user
as
begin
--- select userid, username, activedeactive from usertable
   select 23 , 'sampleuser23' , 1 union all
   select 53 , 'sampleuser53' , 1 union all
   select 26 , 'sampleuser26' , 1 union all
   select 73 , 'sampleuser73' , 0
end
0
 
informaniacCommented:
DataSet1 ds = new DataSet1();

gv.DataSource = ds.Tables[0];
gv.DataBind();

Open in new window

0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
dyaroshAuthor Commented:
I knew how to do it programmatically.  What I really want to be able to do is to do it in the IDE so I can format the gridview and set it up for editing.  

So maybe a better question is how can I create a DataSet that is not tied to a database.  If I have to I could create an XML file or Text file to simulate the database but I was hoping I could just define the tables in the DataSet and then programmatically populate the tables in the DataSet.  If the DataSet and tables existed in the IDE I would then use it to bind to different controls on my form and then once the database on my system can be changed I would modify my DataSet to be configured to my database.

Am I making more sense?
0
 
informaniacCommented:
I don't think you can bind a typed dataset to gridview in design time. You have to do it from server-side.

Alternatively I think you could just creat an XML file and bind the Gridview using a XMLDataSource. That way you can do it designtime.
0
 
dyaroshAuthor Commented:
So if I create an XML file and bind the Gridview using an XMLDataSource I should be able to format the Grid the way I want it to look and behave.  When I am finally able to make the changes to my SQL Database, do I just change my datasource on my DataSet if the tables are laid out the same?  Will I have to change anything with the Gridview processing?
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now