IT Community - Software Programming, Web Development and Technical Support

Create database object with dynamically

This is a discussion on Create database object with dynamically within the C# Programming forums, part of the Software Development category; Hi all, I'm going to populate a datagrid with some data. The data will be from an object that ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 09-22-2007, 07:01 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Question Create database object with dynamically

Hi all,


I'm going to populate a datagrid with some data. The data will be from an object that populated by a query.


So I pull data from my database, but now Im having trouble wondering how I can get data from my database into the data grid!

Would anyone be able to help me as im kind of stuck.
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-25-2007, 04:09 AM
mobilegeek mobilegeek is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 205
mobilegeek is on a distinguished road
Cool Re: Create database object with dynamically

Vinoth,

You can create property classes for your tables and get the db values in to that classes.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-25-2007, 04:14 AM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 325
amansundar is on a distinguished road
Wink Re: Create database object with dynamically

Hello vinoth,

Does your object implement IEnumerable?

If it does implement this interface, you'll be able to use the typical DataBind() method.
__________________
cheers
Aman
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-25-2007, 04:19 AM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 325
amansundar is on a distinguished road
Exclamation Re: Create database object with dynamically

What methods does your object expose? Does it have a method such as Read() that will allow you to iterate through its values?
__________________
cheers
Aman
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-25-2007, 10:59 PM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Question Re: Create database object with dynamically

Yes,

It has a Read() Method, which i can run through each row in the resultset.

I just have no idea how to populate an object, based on the current field.
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 09-27-2007, 12:20 AM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 325
amansundar is on a distinguished road
Smile Re: Create database object with dynamically

You should be able to loop and retrieve the data using something such as:
Code:
while(theObject.Read())
{
    Response.Write(theObject["ColumnName"]);
}
What you'll want to do inside the while loop is to create a new DataGrid row, set the values for the cells and add it to your DataGrid.

However, if you don't plan to use the DataGrid specific features, you're better of using a Table object (typical HTML table) and create new rows. It should be easier.
__________________
cheers
Aman
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 09-28-2007, 11:49 PM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Smile Re: Create database object with dynamically

I decided in the end to use a library i made called Dynamic Object, it allows me too generate members for objects dynamically and then later pull them out of the object using a foreach loop without ever knowing the member names. Only problem is the object doesnt actually exist, so it would be impossible to apply methods too the objects, enless the contrainer object extended from a code based object ...

Thanks for the help!
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i create serialized object in PHP? saravanan PHP Programming 1 03-24-2008 06:52 PM
How Create print preview page dynamically in ASP.NET KiruthikaSambandam ASP and ASP.NET Programming 4 03-21-2008 04:42 AM
How can we Dynamically create web controls Kirubhananth ASP and ASP.NET Programming 3 03-14-2008 10:00 PM
Code-behind to create node dynamically using XML File or any Stored Procedure poornima ASP and ASP.NET Programming 3 02-14-2008 09:46 PM
How to create xml dom object and how to use its fucntions in php itbarota PHP Programming 1 07-26-2007 12:10 AM


All times are GMT -7. The time now is 10:55 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0