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
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 children As RowsCollection
ID = Request("ID")
TableName = "crec" & Dropdownlist2.SelectedValue & "0" & DropDownList1.SelectedValue
Else
TableName = "crec" & Dropdownlist2.SelectedValue & DropDownList1.SelectedValue
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
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(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
Phone = children(j).Cells(0).Text
found = 0
If DS.Tables(0).Rows.Count > 0 Then
dr = DS.Tables(0).Rows(i1)
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(2).Value = dr("last_name")
uwgRow.Cells(3).Value = dr("first_name")
uwgRow.Cells(4).Value = dr("site_number")
children(j).Rows.Add(uwgRow)
If found = 1 Then
Exit For
End If
Next
UltraWebGrid2.DisplayLayout.Bands(2).Columns(1).Hidden = True
children1 = children(j).Rows
jMax1 = children1.Count
If jMax1 > 0 Then
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(
uwgRow1.Cells(0).Value = dr1("phone")
uwggRow1.Cells.Add(New Infragistics.WebUI.UltraWebGrid.UltraGridCell)
uwgRow1.Cells(1).Value = ""
uwgRow1.Cells(2).Value = ""
children1(j1).Rows.Add(uwgRow1)
UltraWebGrid2.Visible = True
End Sub
Hi,
What's your finding or solutions for this, please? I need to do similar things too. Thanks.
I'm doing a research on this and will be back with my findings.
Thanks
But I need to add 2 Band
First I added 1 Band, added colums for this band and added rows, then added next band , added colums to this band and try to add rows I don't know why but I think problem with
when this is comment , code is working , only I have 3 bands but need to have 4
Thanks to advise
I went throught the code and found the UltraGridBand object "Band" is added twice to the same grid.
bdrutman said: 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
Then the columns added to the Bands are different. I was wondering, if this the block of code where you are getting the error? Please let me know in details what you are trying to achieve.
Sarita