We help IT Professionals succeed at work.

Substitute variable name for gridview name

KavyaVS
KavyaVS asked
on
dim dt as DataTable

'Get results from database

Dim arrString(dt.Rows.Count - 1) As String

Dim iCnt as Integer

for iCnt = 0 to dt.Rows.Count - 1

    arrString(iCnt) = dt.Rows(iCnt)("column1")
    Dim strGridcount As String = iCnt.ToString()
    Dim dv+strGridcount As New DataView(dt, " Desc = '" & arrString(iCnt) & "'", "displayorder ASC", DataViewRowState.CurrentRows)

next
The above one is giving me error at dv+strGridcount As New DataView
Basically I want to generate dv0,dv1............dv(dt.Rows.Count-1) grid views

How to declare gridview name based on counter variable.

Thanks
Comment
Watch Question

Commented:
Dim strGridcount As String
Dim dv As DataView

for iCnt = 0 to dt.Rows.Count - 1

    arrString(iCnt) = dt.Rows(iCnt)("column1")
    strGridcount = iCnt.ToString()
    dv = New DataView(dt, " Desc = '" & arrString(iCnt) & "'", "displayorder ASC", DataViewRowState.CurrentRows)
    dv.Name = strGridcount
    dv.ID = strGridcount

next
BRONZE EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
>strGridcount = iCnt.ToString()

strGridcount = "dv" & iCnt.ToString()

Explore More ContentExplore courses, solutions, and other research materials related to this topic.