Hi Team,
In My application using dropdown list 2 differente data source in side multiview control while assigning the datasouce time as i am getting " Object reference not set to an instance of an object." find the .aspx
<asp:MultiView ID="MultiView1" runat="server"> <asp:View ID="vAccounting" runat="server"> <%--<asp:Panel ID="pnlAccounting" runat="server">--%> <igrid:WebDataGrid ID="uwgAccounting" Height="420px" AutoGenerateColumns="False" runat="server" Width="100%" EnableAjax="False" EnableDataViewState="false" EnableViewState="false" EnableTheming="False" ItemCssClass="clsRowitem"> <Columns> <igrid:UnboundField Header-Text="Tank" Key="TankNameTag" Header-CssClass="Headercaption"> </igrid:UnboundField> <igrid:UnboundField Header-Text="Last Service Change" Key="TimeStamp" Header-CssClass="Headercaption" Width="140px"> </igrid:UnboundField> <igrid:GroupField Key="AP" Header-Text="Accounting Product" Header-CssClass="Headercaption"> <Columns> <igrid:UnboundField Header-Text="Code" Key="ActgPrCode" Header-CssClass="Headercaption"> </igrid:UnboundField> <igrid:UnboundField Header-Text="Description" Key="ActgPrDesc" Header-CssClass="Headercaption" Width="180px"> </igrid:UnboundField> </Columns> </igrid:GroupField> <igrid:GroupField Key="APG" Header-Text="Accounting Product Group" Header-CssClass="Headercaption"> <Columns> <igrid:UnboundField Header-Text="Code" Key="PrGroupCode" Header-CssClass="Headercaption"> </igrid:UnboundField> <igrid:UnboundField Header-Text="Description" Key="PrGroupDesc" Header-CssClass="Headercaption" Width="150px"> </igrid:UnboundField> </Columns> </igrid:GroupField> <igrid:UnboundField Header-Text="Chgd By" Key="ActgProductUser" Header-CssClass="Headercaption"> </igrid:UnboundField> </Columns> </igrid:WebDataGrid> <%--</asp:Panel>--%> </asp:View> <asp:View ID="vPlanning" runat="server"> <%--<asp:Panel ID="pnlPlanning" runat="server">--%> <igrid:WebDataGrid ID="uwgPlanning" CssClass="FrameStyle" Height="420px" AutoGenerateColumns="False" runat="server" Width="100%" EnableAjax="False" EnableDataViewState="false" EnableViewState="false" EnableTheming="False"> <Columns> <igrid:UnboundField Header-Text="Tank" Key="TankNameTag" Header-CssClass="Headercaption"> </igrid:UnboundField> <igrid:UnboundField Header-Text="Last Service Change" Key="TimeStamp" Header-CssClass="Headercaption"> </igrid:UnboundField> <igrid:GroupField Key="AP" Header-Text="Accounting Product" Header-CssClass="Headercaption"> <Columns> <igrid:UnboundField Header-Text="Code" Key="ActgPrCode" Header-CssClass="Headercaption"> </igrid:UnboundField> <igrid:UnboundField Header-Text="Description" Key="ActgPrDesc" Header-CssClass="Headercaption"> </igrid:UnboundField> </Columns> </igrid:GroupField> <igrid:GroupField Key="PP" Header-Text="Planning Product" Header-CssClass="Headercaption"> <Columns> <igrid:UnboundField Header-Text="Group" Key="PlngGroup" Header-CssClass="Headercaption"> </igrid:UnboundField> <igrid:UnboundField Header-Text="Subgroup1" Key="PlngSubgroup1" Header-CssClass="Headercaption"> </igrid:UnboundField> <igrid:UnboundField Header-Text="Subgroup2" Key="PlngSubgroup2" Header-CssClass="Headercaption"> </igrid:UnboundField> </Columns> </igrid:GroupField> <igrid:UnboundField Header-Text="Chgd By" Key="ActgProductUser" Header-CssClass="Headercaption"> </igrid:UnboundField> </Columns> </igrid:WebDataGrid> <%--</asp:Panel>--%> </asp:View> <asp:View ID="viewTankProperties" runat="server"> <%--<asp:Panel ID="pnlTankProPerties" runat="server">--%> <igrid:WebDataGrid ID="uwgTankProperties" CssClass="FrameStyle" Height="380px" AutoGenerateColumns="False" runat="server" Width="100%" HeaderCaptionCssClass="HeaderCaptionClass" EnableAjax="False" ItemCssClass="RowBackGround" EnableDataViewState="false" EnableViewState="false"> <Columns> <igrid:UnboundField Header-Text="Tag" Key="TagName"> </igrid:UnboundField> <igrid:UnboundField Header-Text="Property" Key="Name"> </igrid:UnboundField> <igrid:UnboundField Header-Text="Value" Key="Value"> </igrid:UnboundField> <igrid:UnboundField Header-Text="UOM" Key="UOM"> </igrid:UnboundField> </Columns> </igrid:WebDataGrid> <%--</asp:Panel>--%> </asp:View> </asp:MultiView>
.Net code :
Dim tankList As TankCollection = Nothing Dim actgProdList As ProductCollection = Nothing Dim tankObj As Tank = Nothing Try strTankName = tankName If TypeOf (dataObj) Is TankCollection Then 'If DataObj is TankCollection tankList = CType(dataObj, TankCollection) ElseIf TypeOf (dataObj) Is ProductCollection Then 'If DataObj is ProductCollection actgProdList = CType(dataObj, ProductCollection) ElseIf TypeOf (dataObj) Is Tank Then 'If DataObj is Tank tankObj = CType(dataObj, Tank) End If 'User Selected the Tank Properties from tank history operations If operId = 3 Then 'Bind the Tank Object tag list to Grid uwgTankProperties.DataSource = tankObj.TagList() uwgTankProperties.DataBind() 'Turn on View to show Me.MultiView1.SetActiveView(viewTankProperties) Else 'for all other operation in Tank History and Tank Service changes If DefaultTankCodeView.Equals("A") Then 'View is Accounting 'No Operation Selected or Daily Values operation selected
uwgPlanning.ClearDataSource() uwgPlanning.Rows.Clear() uwgAccounting.Rows.Clear()
If operId = -1 OrElse operId = 1 Then uwgAccounting.DataSource = tankList Else 'Recorded Values uwgAccounting.DataSource = actgProdList End If uwgAccounting.DataBind()
'Turn on View Me.MultiView1.SetActiveView(vAccounting) ElseIf DefaultTankCodeView.Equals("P") Then 'View is Planning 'No Operation Selected or Daily Values operation selected
uwgAccounting.ClearDataSource() uwgAccounting.Rows.Clear() uwgPlanning.Rows.Clear()
If operId = -1 OrElse operId = 1 Then uwgPlanning.DataSource = tankList Else 'Recorded Values uwgPlanning.DataSource = actgProdList End If
uwgPlanning.DataBind() 'Turn on View Me.MultiView1.SetActiveView(vPlanning) End If End If
using cleardatasource(),row.clear() every thing still getting the error please share the solution
Thanks
Ranhganathan palanisamy
Hello Ranhganathan,
Please do not hesitate to contact me if you are still experiencing any issues.
Hi Ranhganathan,
Thank you for posting in the community.
I can see no obvious issues with the way you are changing the datasource (altough clearing the rows should not be necessary after calling ClearDataSource()). I can suggest that you try your scenario without explicitly calling DataBind() after reassigning the datasource .In order to provide more specific feedback I would need a small sample with the actual datasource in order to effectively debug this.
Please feel free to contact me if you have any questions.