473,655 Members | 3,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET dynamically create datagrid and set its datasource

Donna Mar 15, 10:11 am show options

Newsgroups: microsoft.publi c.dotnet.framew ork.adonet
From: "Donna" <dyw...@yahoo.c om> - Find messages by this author
Date: 15 Mar 2005 10:11:56 -0800
Local: Tues, Mar 15 2005 10:11 am
Subject: VB.NET dynamically create datagrid and set its datasource
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

I try to dynamically add datagrid to my web form in VB.NET. But when I

try to setup the datasource, the DATASOURCE is not the property of
datagrid. Anybody know the reason?
I tried the same thing in C#, the DATASOURCE is the property of
datagrid and it works great.
thanks for your help

Nov 19 '05 #1
4 6190
Hi Donna:

DataSource is a property available on a DataGrid for all the
languages. Are you saying DataSource doesn't appear in the properties
window? Or doesn't compile?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On 15 Mar 2005 10:33:17 -0800, dy****@yahoo.co m wrote:
Donna Mar 15, 10:11 am show options

Newsgroups: microsoft.publi c.dotnet.framew ork.adonet
From: "Donna" <dyw...@yahoo.c om> - Find messages by this author
Date: 15 Mar 2005 10:11:56 -0800
Local: Tues, Mar 15 2005 10:11 am
Subject: VB.NET dynamically create datagrid and set its datasource
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

I try to dynamically add datagrid to my web form in VB.NET. But when I

try to setup the datasource, the DATASOURCE is not the property of
datagrid. Anybody know the reason?
I tried the same thing in C#, the DATASOURCE is the property of
datagrid and it works great.
thanks for your help


Nov 19 '05 #2
Actually datasource is not the property of datagrid when you create the
datagrid in the run time instead of design time. Here is the code
Public Sub CreateGrid()
'declare a new datagrid and set properties
Dim DataGrid1 As New DataGrid()

'bind datagrid
'************** *************** ********
'I will get error in here and tell me that
'datasource is not the property of DataGrid1
DataGrid1.DataS ource = GetDataSet()
DataGrid1.DataB ind()

'add datagrid to the page
Page.Controls(1 ).Controls.Add( DataGrid1)

End Sub

Any thought?
thanks

Scott Allen wrote:
Hi Donna:

DataSource is a property available on a DataGrid for all the
languages. Are you saying DataSource doesn't appear in the properties
window? Or doesn't compile?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On 15 Mar 2005 10:33:17 -0800, dy****@yahoo.co m wrote:
Donna Mar 15, 10:11 am show options

Newsgroups: microsoft.publi c.dotnet.framew ork.adonet
From: "Donna" <dyw...@yahoo.c om> - Find messages by this author
Date: 15 Mar 2005 10:11:56 -0800
Local: Tues, Mar 15 2005 10:11 am
Subject: VB.NET dynamically create datagrid and set its datasource
Reply | Reply to Author | Forward | Print | Individual Message | Showoriginal | Report Abuse

I try to dynamically add datagrid to my web form in VB.NET. But when I
try to setup the datasource, the DATASOURCE is not the property of
datagrid. Anybody know the reason?
I tried the same thing in C#, the DATASOURCE is the property of
datagrid and it works great.
thanks for your help


Nov 19 '05 #3
Hi:
On 15 Mar 2005 19:06:40 -0800, dy****@yahoo.co m wrote:
Actually datasource is not the property of datagrid when you create the
datagrid in the run time instead of design time. Here is the code
Public Sub CreateGrid()
'declare a new datagrid and set properties
Dim DataGrid1 As New DataGrid()

'bind datagrid
'************** *************** ********
'I will get error in here and tell me that
'datasource is not the property of DataGrid1
DataGrid1.DataS ource = GetDataSet()
DataGrid1.DataB ind()

'add datagrid to the page
Page.Controls(1 ).Controls.Add( DataGrid1)

End Sub

Any thought?
thanks


That seems odd, the only thing I can think of is that you have another
class by the name of DataGrid. Try:

Dim DataGrid1 As New System.Web.UI.W ebControls.Data Grid

Any luck?

--
Scott
http://www.OdeToCode.com/blogs/scott/
Nov 19 '05 #4
Scott,
Thank you very much. I thought that I import the
System.Web.UI.W ebControls, then I could use datagrid directly. You
are right that there should be another class called datagrid somewhere
which I even did not know it exists. Thanks again

Donna

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1120
by: VM | last post by:
If I'm filling a DataTable and, in the middle of the table fill, I set the datagrid.datasource to this table, how can I stop the grid from reflecting the changes from the table after I set the dartasource? Since I' m not sure I'm explainng it well, here's some pseudocode: for (int i =0;i<20000;i++) { rowAudit = mytable.NewRow(); // Code fills rowAudit mytable.Rows.Add(rowAudit);
0
1184
by: Billy | last post by:
I have a web page with a control (Control#A) on it. The control (#A) has a control (Control#B) on it which displays an exception message when set and displayed. I am creating a simple datagrid dynamically with delegates and assigning it to a placeholder on control #A. If, within a delegate of the dynamically built datagrid, I set a property on control #B, it sets fine but fails to reflect this on the displayed page. There is no...
2
2203
by: Quentin Huo | last post by:
Hi: I have a user control and I want to dynamically create a Label control and TextBox control when the button "add more author name" is clicked. I did like this: 1. there is a "PlaceHolder" control "ph" in the user control; 2. create a Label control and TextBox control when in the "add" button
6
1957
by: vips | last post by:
Page_Load datagrid1.datasource=dataset1 //I am filling the datagrid and it works fine when page is displayed end ---------------
7
6783
by: pmclinn | last post by:
I was wondering if it is possible to dynamically create a structure. Something like this: public sub main sql = "Select Col1, Col2 from Table a" dim al as new arraylist al = LoadOracleData(sql) '____Do amazing things
4
5207
by: Narshe | last post by:
If I create a datagrid, and set a source and bind it, the data shows up fine. When a postback occurs, the DataGrid.DataSource == null. Is there something in the web.config I'm missing? This is on asp.net 2.0.
0
1129
by: rockdale | last post by:
private void dgrid_OnItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if(e.Item.ItemType ==ListItemType.Item||e.Item.ItemType ==ListItemType.AlternatingItem) DataRowView drv = (DataRowView)e.Item.DataItem; it caught error.
1
2079
by: Ryan Liu | last post by:
Hi, If a DataGrid.DataSource is an IList, not a DataTable, is there a way similar to dt.AcceptChanges(), dt.RejectChanges()? Thanks a lot! Ryan Liu
3
4358
by: rn5a | last post by:
A SqlDataReader is populated with the records from a SQL Server 2005 DB table. The records retrieved depends upon 2 conditions (the conditions depend on what a user selects in an ASPX page). If condition1 is true, then the SqlDataReader will be populated with the records existing in table1 & will return 0 to the calling function but if condition2 is true, then the SqlDataReader will be populated with the records from another table named...
0
8816
Oralloy
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...
0
8710
jinu1996
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...
0
8598
tracyyun
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...
1
6162
isladogs
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...
0
5627
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();...
0
4150
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...
0
4299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1598
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.