Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Override Datagrid from function

Reply
Thread Tools

Override Datagrid from function

 
 
Yuriy Solodkyy
Guest
Posts: n/a
 
      06-11-2007
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



 
Reply With Quote
 
 
 
 
Ralf Rennartz
Guest
Posts: n/a
 
      06-11-2007
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


 
Reply With Quote
 
 
 
 
Yuriy Solodkyy
Guest
Posts: n/a
 
      06-11-2007

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" <(E-Mail Removed)> schrieb im Newsbeitrag
> news:(E-Mail Removed) 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



 
Reply With Quote
 
Ralf Rennartz
Guest
Posts: n/a
 
      06-11-2007
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" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed) 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

>
>



 
Reply With Quote
 
Ralf Rennartz
Guest
Posts: n/a
 
      06-11-2007
You are right: Placeholder works fine.
Thanks!

Greets
Ralf





"Yuriy Solodkyy" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed) 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

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why a member function will override an free function with the samename even if the arguments does not match? Peng Yu C++ 4 09-20-2008 02:00 PM
Override VisitedLink color in Datagrid Header VB VS2003 smcirish ASP .Net 0 04-22-2008 04:05 PM
How override ALL function calls? (Is there a "function call function"?) seberino@spawar.navy.mil Python 2 08-01-2005 12:38 PM
Edit All Function for DataGrid, and Moving the Edit Function in a DataGrid Schultz ASP .Net 3 02-14-2005 04:47 AM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM



Advertisments