Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

MyGridViewRow Class - ASP.NET

RSS
Modified on Sat, Sep 26, 2009, 6:40 PM by Administrator Categorized as ASP·NET Web Forms, Class Library
This page is part of the Class Library Pages collection.
Click the icon to see the index.

Sample Implementation

In the GridView's RowDataBound event handler...

Dim g As MyGridViewRow = New MyGridViewRow(e.Row)
Dim d As MyDataSet.MyRow = g.DataRow
g.uxOrderIdLabel.Text = d.OrderId.ToString()

' TODO: Populate other controls similarly.

Source Code

VB.NET

Imports Microsoft.VisualBasic
Imports System.Data

Public Class MyGridViewRow

    Private _gvRow As GridViewRow

    '== Constructor and Public Methods ============================================================
    Public Sub New(ByVal gvRow As GridViewRow)

        _gvRow = gvRow

    End Sub
    Public ReadOnly Property DataRow() As MyDataSet.MyRow
        Get
            Return CType(CType(_gvRow.DataItem, DataRowView).Row, MyDataSet.MyRow)
        End Get
    End Property

    '== Private Functions =========================================================================
    Private Function FindControl(Of ControlType As {Control})(ByVal id As String) As ControlType

        Dim result As ControlType = Nothing
        Dim ctl As Object = _gvRow.FindControl(id)

        If ctl IsNot Nothing Then
            result = CType(ctl, ControlType)
        End If

        Return result

    End Function

    '== Control Properties ========================================================================
    '   TODO: Create one read-only property per control on your grid view row
    Public ReadOnly Property uxNameLabel() As Label
        Get
            Return FindControl(Of Label)("uxNameLabel")
        End Get
    End Property

End Class

C#

 TODO 

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2018, Patrick Jasinski.