Professional Web Applications Themes

Nested Datagrids - ASP.NET Data Grid Control

I can imagine two possible solutions: 1. Create your own datagrid deriving from asp.net datagrid and put this behavior on it (showing a special message when empty). I guess it's a more generic solution for the problem. 2. write code on the OnItemCreated event of your parent datagrid and get the child instance from the Controls collection. At this time, you can do whatever you want with the child grid (hide it, for example). "Dave" <davet65109hotmail.com> wrote in message news:076b01c34a2b$90520790$a001280aphx.gbl... > I have a DataGrid nested within another DataGrid whose > DataSource is Container.DataItem.CreateChildView > ("RelationName"). In some cases, there ...

  1. #1

    Default Re: Nested Datagrids

    I can imagine two possible solutions:

    1. Create your own datagrid deriving from asp.net datagrid and put this
    behavior on it (showing a special message when empty). I guess it's a more
    generic solution for the problem.

    2. write code on the OnItemCreated event of your parent datagrid and get the
    child instance from the Controls collection. At this time, you can do
    whatever you want with the child grid (hide it, for example).



    "Dave" <davet65109hotmail.com> wrote in message
    news:076b01c34a2b$90520790$a001280aphx.gbl...
    > I have a DataGrid nested within another DataGrid whose
    > DataSource is Container.DataItem.CreateChildView
    > ("RelationName"). In some cases, there will be no data
    > for the nested DataGrid and I want to display a message
    > saying that. So my questions are (1) how can I address
    > the nested DataGrid to set .Visible=false and (2) how can
    > I establish that there is no data? Normally I would just
    > interrogate the DataGrid.Items.Count but with the
    > potential for more than one of them, I'm uncertain how to
    > proceed.
    >
    > Thanks...

    Juliano Bortolozzi Guest

  2. #2

    Default Nested DataGrids

    I have a datagrid with another datagrid in a template
    column. For the second datagrids datasource I use
    container.dataitem.createchildview("relationship") I want
    to discover if the nested datagrid has any rows. I think
    I need to check the datagrid.items.count on the second
    datagrid in the first datagrids ItemCreated event but I
    can't seem to figure out how to address the second
    datagrid. Does anyone have any ideas?
    Dave Guest

  3. #3

    Default Re: Nested DataGrids

    Use the "FindControl" method to get the second datagrid object.

    Justin

    "Dave" <davet65109hotmail.com> wrote in message
    news:023101c34aef$0c7f3bd0$a101280aphx.gbl...
    > I have a datagrid with another datagrid in a template
    > column. For the second datagrids datasource I use
    > container.dataitem.createchildview("relationship") I want
    > to discover if the nested datagrid has any rows. I think
    > I need to check the datagrid.items.count on the second
    > datagrid in the first datagrids ItemCreated event but I
    > can't seem to figure out how to address the second
    > datagrid. Does anyone have any ideas?

    S. Justin Gengo Guest

  4. #4

    Default Nested DataGrids

    If you drop a datagrid into an itemtemplate column of a
    datagrid using VS.net, it doesn't get declared in the
    designer code with

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

    I presume that is why you can't pick up the ItemCommand
    event of the NestedGrid if it has an ImageButton in it.
    That being the case, does anyone know what you must do to
    pick up the event?

    I added the declaration but it didn't help. Seems like
    you must pick up the datagrid somehow by accessing it
    through the cells of the datagrid that contains it.

    Thanks


    Dave Guest

  5. #5

    Default Re: Nested DataGrids

    Hi Dave,

    Here are a couple of articles on nested datagrids that might help:

    [url]http://www.standardio.org/article.aspx?id=155[/url]

    [url]http://www.developer.com/db/article.php/10920_2228761_1[/url]

    Good luck!

    --
    Ray Dixon - Microsoft MVP
    [email]rayNOSPAM.greeble.com[/email]
    (remove NOSPAM. from my e-mail address for a direct reply)


    "Dave" <davet65109hotmail.com> wrote in message
    news:048e01c34f85$dc2a4bf0$a001280aphx.gbl...
    > If you drop a datagrid into an itemtemplate column of a
    > datagrid using VS.net, it doesn't get declared in the
    > designer code with
    >
    > Protected WithEvents NestedGrid As
    > System.Web.UI.WebControls.DataGrid
    >
    > I presume that is why you can't pick up the ItemCommand
    > event of the NestedGrid if it has an ImageButton in it.
    > That being the case, does anyone know what you must do to
    > pick up the event?
    >
    > I added the declaration but it didn't help. Seems like
    > you must pick up the datagrid somehow by accessing it
    > through the cells of the datagrid that contains it.
    >
    > Thanks
    >
    >

    Ray Dixon [MVP] Guest

  6. #6

    Default Nested Datagrids

    I have a datagrid nested in another and I am able to delet the rows in
    outer datgrid, which delete a row and the nested datagrid corresponing
    to that row. But I wouldalso like to have a functionality where in I
    would like to delete a single row in the inner datagrid. Any
    help/pinter appreciated.

    Thanks.
    Atif Jalal Guest

  7. #7

    Default nested datagrids

    I need to implement a grid within a grid. How can I do this.
    The reason I need to do this is because I need to show related data within a
    grid from two different tables.

    source


    source Guest

  8. #8

    Default Re: nested datagrids

    source wrote:
    > I need to implement a grid within a grid. How can I do this.
    > The reason I need to do this is because I need to show related data
    > within a grid from two different tables.
    >
    > source
    Put the second grid in the ItemTemplate of the first grid.
    Use the OnItemBound event of the first grid to bind the second grid.

    --

    Jos


    Jos Guest

  9. #9

    Default Re: nested datagrids

    As a matter of fact I tried using a datagrid within the ItemTemplate, but
    for some reason it did not work.
    Can you tell me little more about this.


    "Jos" <josnospambrandersfastmail.fm> wrote in message
    news:eKmuA1xtDHA.3416tk2msftngp13.phx.gbl...
    > source wrote:
    > > I need to implement a grid within a grid. How can I do this.
    > > The reason I need to do this is because I need to show related data
    > > within a grid from two different tables.
    > >
    > > source
    >
    > Put the second grid in the ItemTemplate of the first grid.
    > Use the OnItemBound event of the first grid to bind the second grid.
    >
    > --
    >
    > Jos
    >
    >

    source Guest

  10. #10

    Default Re: nested datagrids

    source wrote:
    > As a matter of fact I tried using a datagrid within the ItemTemplate,
    > but for some reason it did not work.
    > Can you tell me little more about this.
    In the OnItemDataBound() event for the main datagrid, find the nested
    datagrid like this:

    Dim ndg As DataGrid = CType(e.Item.FindControl("DataGrid2",DataGrid))

    Then perform databinding on it:

    ndg.DataSource=whatever (probably depending on some data in e.Item)
    ndg.DataBind()

    Here's some examples with repeaters instead of datagrids:
    [url]http://www.c-sharpcorner.com/Code/2002/Aug/MasterDetailedDisplay.asp[/url]
    [url]http://authors.aspalliance.com/aylar/ViewArticle.aspx?ArticleID=4&PageID=1[/url]

    Here's an example with a datagrid constructed on the fly:
    [url]http://www.dotnetjunkies.com/Tutorial/47792CB0-0990-4BD8-BF84-B6063C4C9BBC.dcik[/url]


    --

    Jos


    Jos Guest

  11. #11

    Default Re: nested datagrids

    [url]http://msdn.microsoft.com/msdnmag/issues/03/10/CuttingEdge/[/url]

    IK
    > I need to implement a grid within a grid. How can I do this.
    > The reason I need to do this is because I need to show related data within
    a
    > grid from two different tables.
    >
    > source
    >
    >

    IK Guest

  12. #12

    Default Nested DataGrids

    Hello,

    I have created a nested datagrid with the help of this
    article: [url]http://www.standardio.org/article.aspx?id=155[/url].
    Now I need to edit the nested datagrid. I thought that it
    was the same task as editing a single datagrid, but it
    doesnt seem so. I created a simple edit handler for my
    nested datagrid and inserted the following code:

    Sub dgNested_Edit(ByVal sender As Object, ByVal e As
    DataGridCommandEventArgs)
    dgNested.EditItemIndex = e.Item.ItemIndex
    end sub

    However I get the error that dgNested is not declared,
    although it is. I guess I have to use somehow findcontrol
    or anything else to get this working. Anybody has any
    experience with editing nested Datagrids?

    Thanks

    Vishal Guest

  13. #13

    Default Re: Nested DataGrids

    Vishal, are you wiring up the EditCommand to the event handler in your
    declarative syntax, like so?

    <asp:DataGrid id="OutterDataGrid" ...>
    <Columns>
    ...
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:DataGrid id="InnerDataGrid" OnEditCommand="dgNested_Edit"
    .... />
    </ItemTemplate>
    </asp:TemplateColumn>
    ...
    </Columns>
    </asp:DataGrid>

    ???

    Now, you won't be able to access dgNested directly from the EditCommand
    event handler, but the sender parameter passed into the event handler
    is, IIRC, the Edit button. Now, you can get to the DataGrid like so
    (untested code follows):

    Sub dgNested_Edit(ByVal sender As Object, ByVal e As
    DataGridCommandEventArgs)
    Dim myInnerDG as DataGrid
    Dim myEditButton as Button = CType(sender, Button)

    myInnerDG = CType(myEditButton.Parent.Parent.Parent, DataGrid)

    myInnerDG.EditItemIndex = ...
    end sub


    The Button's Parent is the TableCell it exists in. It's Parent is the
    DataGridItem. And the DataGridItem's parent is the DataGrid. That's
    why we do .Parent.Parent.Parent. Hope this makes sense! :-)


    --

    Scott Mitchell
    [email]mitchell4guysfromrolla.com[/email]
    [url]http://www.4GuysFromRolla.com[/url]

    * When you think ASP.NET, think 4GuysFromRolla.com!
    Scott Mitchell [MVP] Guest

  14. #14

    Default Re: Nested DataGrids

    Thanks for the reply Scott. Yes I am doing it this way.
    When I use your code and press the edit button then I get
    the following error:

    System.InvalidCastException: Specified cast is not valid.

    What can I do here?

    Vishal

    >-----Original Message-----
    >Vishal, are you wiring up the EditCommand to the event
    handler in your
    >declarative syntax, like so?
    >
    ><asp:DataGrid id="OutterDataGrid" ...>
    > <Columns>
    > ...
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <asp:DataGrid id="InnerDataGrid"
    OnEditCommand="dgNested_Edit"
    >.... />
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > ...
    > </Columns>
    ></asp:DataGrid>
    >
    >???
    >
    >Now, you won't be able to access dgNested directly from
    the EditCommand
    >event handler, but the sender parameter passed into the
    event handler
    >is, IIRC, the Edit button. Now, you can get to the
    DataGrid like so
    >(untested code follows):
    >
    >Sub dgNested_Edit(ByVal sender As Object, ByVal e As
    >DataGridCommandEventArgs)
    > Dim myInnerDG as DataGrid
    > Dim myEditButton as Button = CType(sender, Button)
    >
    > myInnerDG = CType(myEditButton.Parent.Parent.Parent,
    DataGrid)
    >
    > myInnerDG.EditItemIndex = ...
    >end sub
    >
    >
    >The Button's Parent is the TableCell it exists in. It's
    Parent is the
    >DataGridItem. And the DataGridItem's parent is the
    DataGrid. That's
    >why we do .Parent.Parent.Parent. Hope this makes
    sense! :-)
    >
    >
    >--
    >
    > Scott Mitchell
    > [email]mitchell4guysfromrolla.com[/email]
    > [url]http://www.4GuysFromRolla.com[/url]
    >
    >* When you think ASP.NET, think 4GuysFromRolla.com!
    >.
    >
    Vishal Guest

  15. #15

    Default Re: Nested DataGrids

    BTW: Isnt the sender the datagrid?

    >-----Original Message-----
    >Thanks for the reply Scott. Yes I am doing it this way.
    >When I use your code and press the edit button then I get
    >the following error:
    >
    >System.InvalidCastException: Specified cast is not valid.
    >
    >What can I do here?
    >
    >Vishal
    >
    >
    >>-----Original Message-----
    >>Vishal, are you wiring up the EditCommand to the event
    >handler in your
    >>declarative syntax, like so?
    >>
    >><asp:DataGrid id="OutterDataGrid" ...>
    >> <Columns>
    >> ...
    >> <asp:TemplateColumn>
    >> <ItemTemplate>
    >> <asp:DataGrid id="InnerDataGrid"
    >OnEditCommand="dgNested_Edit"
    >>.... />
    >> </ItemTemplate>
    >> </asp:TemplateColumn>
    >> ...
    >> </Columns>
    >></asp:DataGrid>
    >>
    >>???
    >>
    >>Now, you won't be able to access dgNested directly from
    >the EditCommand
    >>event handler, but the sender parameter passed into the
    >event handler
    >>is, IIRC, the Edit button. Now, you can get to the
    >DataGrid like so
    >>(untested code follows):
    >>
    >>Sub dgNested_Edit(ByVal sender As Object, ByVal e As
    >>DataGridCommandEventArgs)
    >> Dim myInnerDG as DataGrid
    >> Dim myEditButton as Button = CType(sender, Button)
    >>
    >> myInnerDG = CType
    (myEditButton.Parent.Parent.Parent,
    >DataGrid)
    >>
    >> myInnerDG.EditItemIndex = ...
    >>end sub
    >>
    >>
    >>The Button's Parent is the TableCell it exists in. It's
    >Parent is the
    >>DataGridItem. And the DataGridItem's parent is the
    >DataGrid. That's
    >>why we do .Parent.Parent.Parent. Hope this makes
    >sense! :-)
    >>
    >>
    >>--
    >>
    >> Scott Mitchell
    >> [email]mitchell4guysfromrolla.com[/email]
    >> [url]http://www.4GuysFromRolla.com[/url]
    >>
    >>* When you think ASP.NET, think 4GuysFromRolla.com!
    >>.
    >>
    >.
    >
    Vishal Guest

  16. #16

    Default Re: Nested DataGrids

    Scott,

    I have this code now and it works partially.

    Sub dgNested_Edit(ByVal sender As Object, ByVal e As
    DataGridCommandEventArgs)
    Dim myInnerDG as DataGrid = sender
    response.write(sender.ID)
    'Dim myEditButton as Button = CType(sender, Button)
    'myInnerDG = CType(myEditButton.Parent.Parent.Parent,
    DataGrid)

    myInnerDG.EditItemIndex = e.Item.ItemIndex

    end sub

    However the thing is that when I press the first time the
    button then I dont see the datagrid in edit mode. Although
    the sender.ID is printer. Now when I press the second
    time, then the datagrid is in edit mode. I dont understand
    this. Basically the datagrid goes in edit mode when I
    click the edit button twice. What can cause such a
    behaviour?

    Thanks
    >-----Original Message-----
    >BTW: Isnt the sender the datagrid?
    >
    >
    >>-----Original Message-----
    >>Thanks for the reply Scott. Yes I am doing it this way.
    >>When I use your code and press the edit button then I
    get
    >>the following error:
    >>
    >>System.InvalidCastException: Specified cast is not valid.
    >>
    >>What can I do here?
    >>
    >>Vishal
    >>
    >>
    >>>-----Original Message-----
    >>>Vishal, are you wiring up the EditCommand to the event
    >>handler in your
    >>>declarative syntax, like so?
    >>>
    >>><asp:DataGrid id="OutterDataGrid" ...>
    >>> <Columns>
    >>> ...
    >>> <asp:TemplateColumn>
    >>> <ItemTemplate>
    >>> <asp:DataGrid id="InnerDataGrid"
    >>OnEditCommand="dgNested_Edit"
    >>>.... />
    >>> </ItemTemplate>
    >>> </asp:TemplateColumn>
    >>> ...
    >>> </Columns>
    >>></asp:DataGrid>
    >>>
    >>>???
    >>>
    >>>Now, you won't be able to access dgNested directly from
    >>the EditCommand
    >>>event handler, but the sender parameter passed into the
    >>event handler
    >>>is, IIRC, the Edit button. Now, you can get to the
    >>DataGrid like so
    >>>(untested code follows):
    >>>
    >>>Sub dgNested_Edit(ByVal sender As Object, ByVal e As
    >>>DataGridCommandEventArgs)
    >>> Dim myInnerDG as DataGrid
    >>> Dim myEditButton as Button = CType(sender, Button)
    >>>
    >>> myInnerDG = CType
    >(myEditButton.Parent.Parent.Parent,
    >>DataGrid)
    >>>
    >>> myInnerDG.EditItemIndex = ...
    >>>end sub
    >>>
    >>>
    >>>The Button's Parent is the TableCell it exists in.
    It's
    >>Parent is the
    >>>DataGridItem. And the DataGridItem's parent is the
    >>DataGrid. That's
    >>>why we do .Parent.Parent.Parent. Hope this makes
    >>sense! :-)
    >>>
    >>>
    >>>--
    >>>
    >>> Scott Mitchell
    >>> [email]mitchell4guysfromrolla.com[/email]
    >>> [url]http://www.4GuysFromRolla.com[/url]
    >>>
    >>>* When you think ASP.NET, think 4GuysFromRolla.com!
    >>>.
    >>>
    >>.
    >>
    >.
    >
    Vishal Guest

  17. #17

    Default Re: Nested DataGrids

    Please help me scott if you can. I am totally stuck since
    hours.

    >-----Original Message-----
    >Vishal, are you wiring up the EditCommand to the event
    handler in your
    >declarative syntax, like so?
    >
    ><asp:DataGrid id="OutterDataGrid" ...>
    > <Columns>
    > ...
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <asp:DataGrid id="InnerDataGrid"
    OnEditCommand="dgNested_Edit"
    >.... />
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > ...
    > </Columns>
    ></asp:DataGrid>
    >
    >???
    >
    >Now, you won't be able to access dgNested directly from
    the EditCommand
    >event handler, but the sender parameter passed into the
    event handler
    >is, IIRC, the Edit button. Now, you can get to the
    DataGrid like so
    >(untested code follows):
    >
    >Sub dgNested_Edit(ByVal sender As Object, ByVal e As
    >DataGridCommandEventArgs)
    > Dim myInnerDG as DataGrid
    > Dim myEditButton as Button = CType(sender, Button)
    >
    > myInnerDG = CType(myEditButton.Parent.Parent.Parent,
    DataGrid)
    >
    > myInnerDG.EditItemIndex = ...
    >end sub
    >
    >
    >The Button's Parent is the TableCell it exists in. It's
    Parent is the
    >DataGridItem. And the DataGridItem's parent is the
    DataGrid. That's
    >why we do .Parent.Parent.Parent. Hope this makes
    sense! :-)
    >
    >
    >--
    >
    > Scott Mitchell
    > [email]mitchell4guysfromrolla.com[/email]
    > [url]http://www.4GuysFromRolla.com[/url]
    >
    >* When you think ASP.NET, think 4GuysFromRolla.com!
    >.
    >
    Vishal Guest

  18. #18

    Default Re: Nested DataGrids

    Looks like you got it! My bad on the Sender being the Button. This is
    the case if you are using a CheckBox or Button in the TemplateColumn
    whose event is wired up to an event handler. But in the ItemCommand
    it's the DataGrid, as you noted. Jolly good show.

    Cheers.

    --

    Scott Mitchell
    [email]mitchell4guysfromrolla.com[/email]
    [url]http://www.4GuysFromRolla.com[/url]

    * When you think ASP.NET, think 4GuysFromRolla.com!
    Scott Mitchell [MVP] Guest

  19. #19

    Default Re: Nested DataGrids

    Can somebody help here please?

    Vishal.
    >-----Original Message-----
    >Vishal, are you wiring up the EditCommand to the event
    handler in your
    >declarative syntax, like so?
    >
    ><asp:DataGrid id="OutterDataGrid" ...>
    > <Columns>
    > ...
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <asp:DataGrid id="InnerDataGrid"
    OnEditCommand="dgNested_Edit"
    >.... />
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > ...
    > </Columns>
    ></asp:DataGrid>
    >
    >???
    >
    >Now, you won't be able to access dgNested directly from
    the EditCommand
    >event handler, but the sender parameter passed into the
    event handler
    >is, IIRC, the Edit button. Now, you can get to the
    DataGrid like so
    >(untested code follows):
    >
    >Sub dgNested_Edit(ByVal sender As Object, ByVal e As
    >DataGridCommandEventArgs)
    > Dim myInnerDG as DataGrid
    > Dim myEditButton as Button = CType(sender, Button)
    >
    > myInnerDG = CType(myEditButton.Parent.Parent.Parent,
    DataGrid)
    >
    > myInnerDG.EditItemIndex = ...
    >end sub
    >
    >
    >The Button's Parent is the TableCell it exists in. It's
    Parent is the
    >DataGridItem. And the DataGridItem's parent is the
    DataGrid. That's
    >why we do .Parent.Parent.Parent. Hope this makes
    sense! :-)
    >
    >
    >--
    >
    > Scott Mitchell
    > [email]mitchell4guysfromrolla.com[/email]
    > [url]http://www.4GuysFromRolla.com[/url]
    >
    >* When you think ASP.NET, think 4GuysFromRolla.com!
    >.
    >
    Vishal Guest

  20. #20

    Default nested datagrids

    Help! Using nested datagrids in web app using VStudio 2003, IIS, SQLServer.
    Got the data to load just find in both the outer and inner datagrids. I need
    to capture a "select" button click in the inner datagrid, pull the value of
    the button text from the clicked
    button, and use the value to call a sub to populate controls further down in
    the page. I've tried adding
    a handler to the inner datagrid to capture the button click, wired up the
    ItemCommand in the web server control
    in the html page (e.g. onItemCommand="DG_Employee_ItemCommand(... handles
    DG_Employee.ItemCommand), and
    tried assigning it in the outer DG_OnItemDataBound sub (see code below)
    without success. The page does a
    postback, but nothing happens. I've debugged this page to a fare-thee-well
    and am ready to throw the
    computer out the window. I know I'm missing something simple, but can't
    identify it. Anyone have a clue?
    HTML snip and code-behind snips below...

    tia,
    Sue, the frustrated

    ' snip of html page

    <asp:datagrid id="DG" Runat="server" Width="100%">
    <Columns>
    <asp:ButtonColumn ButtonType="LinkButton" CommandName="Select"
    DataTextField="PositionID" Visible="false" />
    <asp:BoundColumn DataField="PositionNumber"
    SortExpression="PositionNumber" HeaderText="Pos No" />
    <asp:BoundColumn DataField="PositionDepartmentDescription"
    SortExpression="PositionDepartmentDescription"
    HeaderText="Dept" />
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:DataGrid ID="DG_Employee" Runat="server" Width="100%">
    <Columns>
    <asp:ButtonColumn ButtonType= "PushButton" CommandName="Select"
    DataTextField="EmployeeID" />
    <asp:BoundColumn ItemStyle-Width="25%" DataField="Name"
    HeaderText="Name" />
    <asp:BoundColumn itemstyle-width="25%"
    DataField="DepartmentDescription" HeaderText="Dept" />
    </Columns>
    </asp:DataGrid>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:datagrid>

    ' code behind page

    Private Sub DG_ItemDataBound(ByVal sender As System.Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles DG.ItemDataBound

    Select Case e.Item.ItemType
    Case ListItemType.Item, ListItemType.AlternatingItem,
    ListItemType.SelectedItem
    Dim button As LinkButton =
    CType(e.Item.Cells(0).Controls(0), LinkButton)
    e.Item.Cells(1).Attributes("onclick") =
    Page.GetPostBackClientHyperlink(button, "")
    e.Item.Cells(2).Attributes("onclick") =
    Page.GetPostBackClientHyperlink(button, "")
    e.Item.Attributes.Add("onmouseover",
    "javascript:this.style.cursor='hand';")


    Dim Details_DG As DataGrid
    Details_DG = CType(e.Item.Cells(3).Controls(1), DataGrid)

    AddHandler Details_DG.ItemCommand, AddressOf
    DG_Employee_ItemCommand

    Details_DG.AutoGenerateColumns = False

    Dim SQLOps As New SQLOperations

    Dim DGE_DS As New DataSet

    ' this function returns a dataset
    DGE_DS = SQLOps.SQLReturnDataSet("select * from detail
    where ID=" & someID)
    ' & " and recordstatus = 'Active' order by Name")
    SQLOps = Nothing

    Details_DG.DataSource = DGE_DS
    Details_DG.DataBind()
    end select

    end sub


    Private Sub DG_ItemCommand(ByVal source As System.Object, ByVal e As
    System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles DG.ItemCommand
    If Not e.CommandName = "Page" Then
    If e.CommandName = "Select" Then
    Session("ThisPositionID") =
    CType(CType(e.Item.Cells(0).Controls(0), System.Web.UI.Control),
    LinkButton).Text
    Call LoadPositionInfo()
    End If
    End If
    End Sub

    Private Sub DG_Employee_ItemCommand(ByVal source As System.Object, ByVal e
    As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
    DG_Employee.ItemCommand
    If Not e.CommandName = "Page" Then
    If e.CommandName = "Select" Then
    Session("ThisEmployeeID") =
    CType(CType(e.Item.Cells(0).Controls(0), System.Web.UI.Control),
    LinkButton).Text
    Call LoadEmployeeInfo()
    End If
    End If
    End Sub
    Sue Guest

Page 1 of 2 12 LastLast

Similar Threads

  1. Paging in nested DataGrids
    By Sonu Kapoor in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: June 14th, 06:19 PM
  2. Nested datagrids or repeaters...etc.
    By Maziar Aflatoun in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: January 30th, 09:52 PM
  3. ddl in datagrids
    By Carl in forum ASP.NET Data Grid Control
    Replies: 2
    Last Post: October 21st, 07:59 PM
  4. Multiple Nested DataGrids
    By Erik in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: July 17th, 02:31 PM
  5. Nested Repeaters or DataGrids and "reporting"
    By Wes Weems in forum ASP.NET General
    Replies: 0
    Last Post: July 3rd, 04:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139