Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Jc Morin #1
Control derived from datagrid, problem with adding other control and databinding (VB)
I all, my employer required me to add a bunch of control to a datagrid (such
as a drop down list on top corner to select page size and prev, bunch page
number adapted to current page, next and other button like export to excel).
All of those control do not required databinding (except of course the base
class Datagrid)
All of those control don't need view state (I will deal with current page
and stuff internaly)
We are already using the .NET datagrid with template so I create a control
that *derived* from the datagrid.
I feel some problem with
- Event from the dropdownlist
- Event from the button added
- Databinding to the base class (DataGrid)
I have only 2 of 3 working at the same time (any combinaison)!!!
If I have only dropdownlist and databinding it work, if I add a button in
the created child control.
I get some other stuff not working.
___
cmdBut = New LinkButton
cmdBut.Text = "Previous"
cmdBut.EnableViewState = False
AddHandler cmdBut.Click, AddressOf SomeActionButton_Click
Me.Controls.Add(cmdBut)
___
I don't need help about composite control that start from strach and add
their control, I need to keep DataGrid method and content working well.
Here is some questions in my head.
Should my control derived from a Datagrid or be composite and have a
Datagrid as member?
Do I have to implements IPostBackDataHandler? (for the dropdownlist maybe)
Do I have to implements IPostBackEventHandler? (for the button maybe)
Shoud I Controls.Clear() in the CreateChildControls() ? (droping my
Datagrid)
I have to overrides CreateControlHierarchy and PrepareControlHierarchy ?
I have to overrides Databind() ?
I would like to have a sample code or help about how to deal with this, else
I gonna copy paste the additive control all over my page :(
Jc Morin Guest
-
Custom Templated Databound Control or derived control?
Hi, I want to create a control that performs much like a datalist but I want more control over how the <ItemTemplate> contents is set out on the... -
Composite Web Custom Control derived from DataGrid
Hello I am a beginner at creating composite web controls. What I am trying to do it add functionality to the DataGrid webcontrol by adding two... -
Custom DataGrid Control - problem with adding BoundColumn
I have created a custom control that derives from a DataGrid: public class SelectableDataGridControl : System.Web.UI.WebControls.DataGrid I have... -
rendering derived control from composite control
I am triing to load a control derived from a datagrid into a composite control so I can wrap some html around the datagrid. it renders the html in... -
Adding Columns at runtime in datagrid control
have a datgrid control that has 3 columns defined at design time. Remaining columns are coming from a query and not known until runtime. I have... -
Jc Morin #2
Re: Control derived from datagrid, problem with adding other control and databinding (VB)
Here is some code to help you helping me :-)
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class PagingDataGrid
Inherits System.Web.UI.WebControls.DataGrid
Protected lstPageSize As New WebControls.DropDownList
Protected cmdPrevious As New LinkButton
Protected cmdNext As New LinkButton
Private Sub InitializeComponent()
Me.EnableViewState = False
End Sub
Protected Overrides Sub CreateChildControls()
'Controls.Clear() ' make everything not working
AddOtherControl()
End Sub
Private Sub AddOtherControl()
If Not (Me.Controls.Contains(lstPageSize)) Then
lstPageSize = New WebControls.DropDownList
lstPageSize.AutoPostBack = True
lstPageSize.EnableViewState = False
lstPageSize.Items.Add("1")
lstPageSize.Items.Add("2")
lstPageSize.Items.Add("3")
AddHandler lstPageSize.SelectedIndexChanged, AddressOf
lstPageSize_SelectedIndexChanged
Controls.Add(lstPageSize)
cmdPrevious = New LinkButton
cmdPrevious.Text = "Previous"
cmdPrevious.EnableViewState = False
AddHandler cmdPrevious.Click, AddressOf PreviousButton_Click
Controls.Add(cmdPrevious)
' ----------------********************-----------------
' adding this make everything not working
'cmdNext = New LinkButton
'cmdNext.Text = "Next"
'cmdNext.EnableViewState = False
'AddHandler cmdNext.Click, AddressOf NextButton_Click
'Controls.Add(cmdNext)
End If
End Sub
Private Sub lstPageSize_SelectedIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs)
Dim setbreakpointhere as Integer = 1
End Sub
Private Sub PreviousButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim setbreakpointhere as Integer = 1
End Sub
Private Sub NextButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim setbreakpointhere as Integer = 1
End Sub
Private Sub PagingDataGrid_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
MyBase.ItemDataBound
CreateChildControls()
ChildControlsCreated = True
End Sub
End Class
"Jc Morin" <jcmorin@2k1soft.com> wrote in message
news:ueJuRRouDHA.2316@TK2MSFTNGP10.phx.gbl...(such> I all, my employer required me to add a bunch of control to a datagridexcel).> as a drop down list on top corner to select page size and prev, bunch page
> number adapted to current page, next and other button like export tobase>
> All of those control do not required databinding (except of course theelse> class Datagrid)
> All of those control don't need view state (I will deal with current page
> and stuff internaly)
>
> We are already using the .NET datagrid with template so I create a control
> that *derived* from the datagrid.
>
> I feel some problem with
> - Event from the dropdownlist
> - Event from the button added
> - Databinding to the base class (DataGrid)
>
> I have only 2 of 3 working at the same time (any combinaison)!!!
> If I have only dropdownlist and databinding it work, if I add a button in
> the created child control.
> I get some other stuff not working.
>
> ___
> cmdBut = New LinkButton
> cmdBut.Text = "Previous"
> cmdBut.EnableViewState = False
> AddHandler cmdBut.Click, AddressOf SomeActionButton_Click
> Me.Controls.Add(cmdBut)
> ___
>
>
> I don't need help about composite control that start from strach and add
> their control, I need to keep DataGrid method and content working well.
>
> Here is some questions in my head.
>
> Should my control derived from a Datagrid or be composite and have a
> Datagrid as member?
> Do I have to implements IPostBackDataHandler? (for the dropdownlist maybe)
> Do I have to implements IPostBackEventHandler? (for the button maybe)
> Shoud I Controls.Clear() in the CreateChildControls() ? (droping my
> Datagrid)
> I have to overrides CreateControlHierarchy and PrepareControlHierarchy ?
> I have to overrides Databind() ?
>
>
> I would like to have a sample code or help about how to deal with this,> I gonna copy paste the additive control all over my page :(
>
>
Jc Morin Guest



Reply With Quote

