473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Override Datagrid from function

Hello NG,

i have the following function which works fine:

Public Shared Function getFullDatagrid() As
System.Web.UI.WebControls.DataGrid

Dim myGrid As New System.Web.UI.WebControls.DataGrid()

Dim bcn1 As New BoundColumn()

bcn1.HeaderText = "T55"

bcn1.DataField = "DocumentID"

myGrid.Columns.Add(bcn1)

myGrid.Enabled = True

myGrid.EnableViewState = True

myGrid.DataSource = getData("test")

myGrid.DataBind()

Return myGrid

End Function
In Page_Load i call the function:

DataGrid1 = getFullDatagrid()

But the datagrid is not displayed. All the propertys like
"DataGrid1.Columns.Count" , "DataGrid1.Items.Count" can be shown in a
layer.

Do you know what is going wrong here?

Thank You
Ralf
Jun 11 '07 #1
4 1318
Hi

Do you add your newly created control to the page? If you create your control
dynamically you need to add it to the page. The simplest way is to put a
PlaceHolder control at your web page and add your grid to the control by
calling:

PlaceHolder1.Controls.Add(myGrid)
-yuriy
Hello NG,

i have the following function which works fine:

Public Shared Function getFullDatagrid() As
System.Web.UI.WebControls.DataGrid

Dim myGrid As New System.Web.UI.WebControls.DataGrid()

Dim bcn1 As New BoundColumn()

bcn1.HeaderText = "T55"

bcn1.DataField = "DocumentID"

myGrid.Columns.Add(bcn1)

myGrid.Enabled = True

myGrid.EnableViewState = True

myGrid.DataSource = getData("test")

myGrid.DataBind()

Return myGrid

End Function

In Page_Load i call the function:

DataGrid1 = getFullDatagrid()

But the datagrid is not displayed. All the propertys like
"DataGrid1.Columns.Count" , "DataGrid1.Items.Count" can be shown in a
layer.

Do you know what is going wrong here?

Thank You
Ralf

Jun 11 '07 #2
Hello,

i have created a datagrid in designview in VS:

Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
.......
' --- This works: DataGrid1 = getData("test")

'This seems to be work fine, but it isnt shown on the screen
DataGrid1 = getFullDatagrid()
Hope You understand what i mean.

Ralf


"Yuriy Solodkyy" <y.************@gmail.comschrieb im Newsbeitrag
news:57***************************@msnews.microsof t.com...
Hi

Do you add your newly created control to the page? If you create your
control dynamically you need to add it to the page. The simplest way is
to put a PlaceHolder control at your web page and add your grid to the
control by calling:

PlaceHolder1.Controls.Add(myGrid)
-yuriy
>Hello NG,

i have the following function which works fine:

Public Shared Function getFullDatagrid() As
System.Web.UI.WebControls.DataGrid

Dim myGrid As New System.Web.UI.WebControls.DataGrid()

Dim bcn1 As New BoundColumn()

bcn1.HeaderText = "T55"

bcn1.DataField = "DocumentID"

myGrid.Columns.Add(bcn1)

myGrid.Enabled = True

myGrid.EnableViewState = True

myGrid.DataSource = getData("test")

myGrid.DataBind()

Return myGrid

End Function

In Page_Load i call the function:

DataGrid1 = getFullDatagrid()

But the datagrid is not displayed. All the propertys like
"DataGrid1.Columns.Count" , "DataGrid1.Items.Count" can be shown in a
layer.

Do you know what is going wrong here?

Thank You
Ralf


Jun 11 '07 #3

As you create new instance of the control you still need to add this newly
added control to the page. You may try adding it to the same parent control
as the old one which is created by the designer.

Try something like:

Dim temp as DataGrid
temp = DataGrid1
DataGrid1 = getFullDatagrid()
temp.Parent.Controls.Add(DataGrid1)

However, I owuld recommend replacing the grid created in designer with PlaceHolder
control and then using dynamic control by adding it to the placeholder.

-yuriy
Hello,

i have created a datagrid in designview in VS:

Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
......

' --- This works: DataGrid1 = getData("test")

'This seems to be work fine, but it isnt shown on the screen DataGrid1
= getFullDatagrid()

Hope You understand what i mean.

Ralf

"Yuriy Solodkyy" <y.************@gmail.comschrieb im Newsbeitrag
news:57***************************@msnews.microsof t.com...
>Hi

Do you add your newly created control to the page? If you create
your control dynamically you need to add it to the page. The
simplest way is to put a PlaceHolder control at your web page and add
your grid to the control by calling:

PlaceHolder1.Controls.Add(myGrid)

-yuriy
>>Hello NG,

i have the following function which works fine:

Public Shared Function getFullDatagrid() As
System.Web.UI.WebControls.DataGrid
Dim myGrid As New System.Web.UI.WebControls.DataGrid()

Dim bcn1 As New BoundColumn()

bcn1.HeaderText = "T55"

bcn1.DataField = "DocumentID"

myGrid.Columns.Add(bcn1)

myGrid.Enabled = True

myGrid.EnableViewState = True

myGrid.DataSource = getData("test")

myGrid.DataBind()

Return myGrid

End Function

In Page_Load i call the function:

DataGrid1 = getFullDatagrid()

But the datagrid is not displayed. All the propertys like
"DataGrid1.Columns.Count" , "DataGrid1.Items.Count" can be shown in
a layer.

Do you know what is going wrong here?

Thank You
Ralf

Jun 11 '07 #4
You are right: Placeholder works fine.
Thanks!

Greets
Ralf

"Yuriy Solodkyy" <y.************@gmail.comschrieb im Newsbeitrag
news:57***************************@msnews.microsof t.com...
Hi

Do you add your newly created control to the page? If you create your
control dynamically you need to add it to the page. The simplest way is
to put a PlaceHolder control at your web page and add your grid to the
control by calling:

PlaceHolder1.Controls.Add(myGrid)
-yuriy
>Hello NG,

i have the following function which works fine:

Public Shared Function getFullDatagrid() As
System.Web.UI.WebControls.DataGrid

Dim myGrid As New System.Web.UI.WebControls.DataGrid()

Dim bcn1 As New BoundColumn()

bcn1.HeaderText = "T55"

bcn1.DataField = "DocumentID"

myGrid.Columns.Add(bcn1)

myGrid.Enabled = True

myGrid.EnableViewState = True

myGrid.DataSource = getData("test")

myGrid.DataBind()

Return myGrid

End Function

In Page_Load i call the function:

DataGrid1 = getFullDatagrid()

But the datagrid is not displayed. All the propertys like
"DataGrid1.Columns.Count" , "DataGrid1.Items.Count" can be shown in a
layer.

Do you know what is going wrong here?

Thank You
Ralf


Jun 11 '07 #5

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

Similar topics

0
by: Andr?s Guerrero | last post by:
Hi, I'm need to test a php script that sends email messages, I'm using a windows local machine (without internet connection), so I can't set an smtp server in php.ini, but I need to see the content...
3
by: Matt | last post by:
Hello, I'm trying to implement the design below. I'd prefer to use commented operator+() in class Number instead of the associated, uncommented operator+(), but as I understand Covariant Return...
2
by: seberino | last post by:
I'm trying run a homegrown profiler on some Python code. Rather than apply profiler wrapper to ALL functions by hand.... Is there a low level Python function I can override to modify how ALL...
1
by: MrNobody | last post by:
Is it at all possible to override the default behavior of a DataGrid when the mouse is clicked on a row? I am having a problem where I am trying to select multiple rows in a DataGrid by...
1
by: Steve | last post by:
I would like to override the IsInputKey function in order to trap the arrow up/down keys in the Key Events. I understand that arrow keys don't have a char representation and thus, hard to trap. ...
0
by: John Smith | last post by:
Is it possible to customize the DataGrid so that I can gain access to the RowHeader colomn? I want to move the Arrow and Pencil graphics down on each row so that it is centered vertically in the...
4
by: mitch | last post by:
Is there a way to reassign a function? I tried this: function func() { alert("func"); } function func2() { alert("func2"); } function testFunc() { document.func = func2; func(); }
2
by: jeremito | last post by:
I have created a class that inherits from the list object. I want to override the append function to allow my class to append several copies at the same time with one function call. I want to do...
1
by: rakeshvthu | last post by:
hi, i have a javascript function in baselayout.jsp for document.onkeydown i want to override it in my other jsp. how can i do that, pls help thanks, Rakesh
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
agi2029
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,...
0
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...

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.