Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Problem with Hierarchical WebGrid
posted

I have Hierarchical Webgrid with 4 Bands

First 2 bands I created from 2 tables when I added relathiomship it works

Then I created a new DataSet and add data to 3 band also is working but when I tied to add data from different RecordSet to 4 Band I all time received an error

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 177:	<tr ><td>
Line 178:	
Line 179:	<igtbl:ultrawebgrid id="UltraWebGrid2" runat="server"  Visible="False" >

Can you help me

Below is my code:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Sub

 

BindGrid()

 

 

Dim MyCommand As  SqlDataAdapter

 

 

Dim MyCommand1 As  SqlDataAdapter

 

 

Dim MyCommand2 As  SqlDataAdapter

 

 

 

 

 

 

 

 

 

 

 

 

Dim ID As Integer

 

 

Dim DS As New  DataSet

 

 

Dim i, i1, i2 As Integer

 

 

Dim iMax As Integer

 

 

Dim jMax, jMax1 As Integer

 

 

Dim j, j1 As  Integer

 

 

Dim Phone As  String

 

 

Dim children As  RowsCollection

 

 

Dim children1 As  RowsCollection

 

 

Dim found As Integer

 

 

Dim strSql As String

 

 

Dim row As  UltraGridRow

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Dim UID As String

 

 

Dim uwgRow As  UltraGridRow

 

ID = Request("ID")

 

 

If DropDownList1.SelectedValue.Length = 1 Then

TableName = "crec" & Dropdownlist2.SelectedValue & "0" & DropDownList1.SelectedValue

 

 

Else

TableName = "crec" & Dropdownlist2.SelectedValue & DropDownList1.SelectedValue

 

 

End If

str = "select a.uid,last_name,first_name,site_number from scanauto_inmlist_xref a,inmate b where a.uid=b.uid and inmlist_id=" & ID & " order by a.uid"

str1 = "select distinct phone,uid from " & TableName & " where uid in (select uid from scanauto_inmlist_xref where inmlist_id=" & ID & ") and xaction_type in (10,11) order by uid "

str2 = "select distinct a.uid,phone,last_name,first_name,site_number from " & TableName & " a,inmate b where a.uid=b.uid and xaction_type in (10,11) and phone in( select phone from " & TableName & " where uid in (select uid from scanauto_inmlist_xref where inmlist_id=" & ID & ") and xaction_type in (10,11)) and a.uid not in (select uid from scanauto_inmlist_xref where inmlist_id=" & ID & ") order by phone "

 

 

MyCommand = New  SqlDataAdapter(str, MyConnection)

MyCommand1 =

New  SqlDataAdapter(str1, MyConnection)

MyCommand2 =

New  SqlDataAdapter(str2, MyConnection)

MyCommand3 = New  SqlDataAdapter(str2, MyConnection)

 

 

 

MyCommand.Fill(batchDataSet1, "scanauto_inmlist_xref")

MyCommand1.Fill(batchDataSet1, "crec1")

MyCommand2.Fill(DS, "crec2")

batchDataSet1.Relations.Add("scanauto_inmlist_xref", batchDataSet1.Tables("scanauto_inmlist_xref").Columns("uid"), batchDataSet1.Tables("crec1").Columns("uid"))

 

 

Me.UltraWebGrid2.DataSource = batchDataSet1.Tables("scanauto_inmlist_xref").DefaultView

 

Me.UltraWebGrid2.DataBind()

UltraWebGrid2.DisplayLayout.Bands(1).Columns(1).Hidden =

True

UltraWebGrid2.DisplayLayout.ViewType = Infragistics.WebUI.UltraWebGrid.ViewType.Hierarchical

 

 

Dim Band As New  Infragistics.WebUI.UltraWebGrid.UltraGridBand

 

 

Dim Band1 As New  Infragistics.WebUI.UltraWebGrid.UltraGridBand

 

 

 

UltraWebGrid2.DisplayLayout.AutoGenerateColumns = False

UltraWebGrid2.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes

UltraWebGrid2.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes

UltraWebGrid2.Bands.Add(Band)

 

 

 

UltraWebGrid2.Bands(2).Columns.Add(0, "UID")

UltraWebGrid2.Bands(2).Columns.Add(1, "Phone")

UltraWebGrid2.Bands(2).Columns.Add(2, "Last Name")

UltraWebGrid2.Bands(2).Columns.Add(3, "First Name")

UltraWebGrid2.Bands(2).Columns.Add(4, "Site Number")

UltraWebGrid2.Bands.Add(Band)

UltraWebGrid2.Bands(3).Columns.Add(0, "Phone")

UltraWebGrid2.Bands(3).Columns.Add(1, "Name")

UltraWebGrid2.Bands(3).Columns.Add(2, "Address")

UltraWebGrid2.DisplayLayout.Bands(3).AllowAdd = AllowAddNew.Yes

UltraWebGrid2.DisplayLayout.Bands(3).AllowUpdate = AllowUpdate.Yes

UltraWebGrid2.DisplayLayout.Bands(2).RowSelectors = RowSelectors.Yes

UltraWebGrid2.DisplayLayout.Bands(2).AllowAdd = AllowAddNew.Yes

UltraWebGrid2.DisplayLayout.Bands(2).AllowUpdate = AllowUpdate.Yes

UltraWebGrid2.DisplayLayout.Bands(3).RowSelectors = RowSelectors.Yes

iMax = UltraWebGrid2.Rows.Count

 

 

For i = 0 To  iMax - 1

 

 

 

 

If UltraWebGrid2.Rows(i).HasChildRows = True Then

children = UltraWebGrid2.Rows(i).Rows

jMax = children.Count

 

 

If jMax > 0  Then

 

 

For j = 0 To  jMax - 1

Phone = children(j).Cells(0).Text

found = 0

 

If DS.Tables(0).Rows.Count > 0  Then

 

 

 

 

 

Dim dr As  DataRow

 

 

For i1 = 0 To  DS.Tables(0).Rows.Count - 1

dr = DS.Tables(0).Rows(i1)

 

 

If Phone = dr("phone")  Then

found = 1

uwgRow =

New UltraGridRow(True)

 

uwgRow.Cells.Add(New  Infragistics.WebUI.UltraWebGrid.UltraGridCell)

uwgRow.Cells(0).Value = dr("uid")

uwgRow.Cells.Add(

New Infragistics.WebUI.UltraWebGrid.UltraGridCell)

uwgRow.Cells(1).Value = dr("phone")

uwgRow.Cells.Add(

New  Infragistics.WebUI.UltraWebGrid.UltraGridCell)

uwgRow.Cells(2).Value = dr("last_name")

uwgRow.Cells.Add(

New  Infragistics.WebUI.UltraWebGrid.UltraGridCell)

uwgRow.Cells(3).Value = dr("first_name")

uwgRow.Cells.Add(

New  Infragistics.WebUI.UltraWebGrid.UltraGridCell)

uwgRow.Cells(4).Value = dr("site_number")

 

 

children(j).Rows.Add(uwgRow)

 

 

Else

 

 

 

 

If found = 1 Then

 Exit For

 

 

End If

 

 

 

Next

 

 

 

End If

 

 

 

Next

 

 

 

 

End If

 

 

End If

 

 

 

Next

 

 

 

UltraWebGrid2.DisplayLayout.Bands(2).Columns(1).Hidden = True

 

 

 

For i = 0 To  iMax - 1

 

 

 

 

 

If UltraWebGrid2.Rows(i).HasChildRows = True Then

children = UltraWebGrid2.Rows(i).Rows

jMax = children.Count

 

 

If jMax > 0  Then

 

 

For j = 0 To  jMax - 1

 

 

If children(j).HasChildRows = True Then

children1 = children(j).Rows

 

 

 

jMax1 = children1.Count

 

 

 

If jMax1 > 0  Then

 

 

For j1 = 0 To  jMax1 - 1

 

 

 

UID = children1(j1).Cells(0).Text

Phone = children1(j1).Cells(1).Text

strSql = "select distinct phone,uid from " & TableName & " where xaction_type in (10,11) and uid<>0 and uid =" &

CInt(UID) & " and phone <>'" & Phone & "' order by phone "

MyCommand3 =

New  SqlDataAdapter(strSql, MyConnection)

 

 

Dim DS1 As New  DataSet

MyCommand3.Fill(DS1, "List")

 

 

Dim dr1 As  DataRow

 

 

If DS1.Tables(0).Rows.Count > 0 Then

 

 

 

For i2 = 0 To  DS1.Tables(0).Rows.Count - 1

dr1 = DS1.Tables(0).Rows(i2)

 

Dim uwgRow1 As UltraGridRow = New UltraGridRow(True)

uwgRow1.Cells.Add(

New  Infragistics.WebUI.UltraWebGrid.UltraGridCell)

uwgRow1.Cells(0).Value = dr1("phone")

 

 

uwggRow1.Cells.Add(New Infragistics.WebUI.UltraWebGrid.UltraGridCell)

uwgRow1.Cells(1).Value = ""

uwgRow1.Cells.Add(

New  Infragistics.WebUI.UltraWebGrid.UltraGridCell)

uwgRow1.Cells(2).Value = ""

 

children1(j1).Rows.Add(uwgRow1)

 

 

 

Next

 

 

 

End If

 

 

 

Next

End  If

 

 

 

End If

 

 

 

Next

End If

 

 

 

End If

 

 

 

Next

 

 

 

UltraWebGrid2.Visible = True

 

 

 

End Sub

Parents Reply Children
No Data