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
105
Object reference not set to an instance of a object
posted

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hi Team,

I am getting error "Object reference not set to an instace of a object" error when I am trying to access any control on the aspx page after adding or deleting a row from a WebDataGrid. Can somebody please let me know what might be the issue?

What is the issur in the below function?

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

public 

 

 

void  GetDropdownCategories()

{_db =

 

DatabaseFactory.CreateDatabase("ISDBConnectionString");

_user =

 

WindowsIdentity.GetCurrent().Name;

 

 

 

DataSet oDs = new DataSet();

 

 

 

DbCommand cmd = _db.GetStoredProcCommand("usp_TSS_Category_S");

cmd.CommandType =

 

CommandType.StoredProcedure;

cmd.Connection = GetISDBConnection();

oDs = _db.ExecuteDataSet(cmd);

 

 

 

 

wddCategory.DataSource = oDs;

wddCategory.TextField =

 

"Category";

wddCategory.ValueField =

 

"CategoryId";

}

The ASPX page is shown below:

<

 

 

body>

 

 

 

<form id="form1" runat="server">

 

 

 

<ig:WebScriptManager ID="WebScriptManager1" runat ="server">

 

 

 

</ig:WebScriptManager>

 

 

 

 

<asp:UpdatePanel ID="up1" runat="server">

 

 

 

<ContentTemplate>

 

 

 

<!--#BEGIN SNIPPET#-->

 

 

 

<asp:ObjectDataSource ID="objCategory" runat="server"

 

 

 

SelectMethod="GetCategories"

 

 

 

UpdateMethod

="UpdateCategory"

 

 

 

InsertMethod

="AddCategory"

 

 

 

DeleteMethod="DeleteCategory"

 

 

 

 

TypeName

="TechnologyServies.Maintenance.ApplicationService">

 

 

 

<UpdateParameters

>

 

 

 

<asp:Parameter Name="categoryId" Type="String" />

 

 

 

<asp:Parameter Name="category" Type="String" />

 

 

 

</UpdateParameters

>

 

 

 

<InsertParameters

>

 

 

 

<asp:Parameter Name="category" Type="String" />

 

 

 

</InsertParameters

>

 

 

 

<DeleteParameters

>

 

 

 

<asp:Parameter Name="categoryId" Type="String"

/>

 

 

 

</DeleteParameters

>

 

 

 

</asp:ObjectDataSource>

 

 

 

<table

>

 

 

 

<tr

>

 

 

 

<td

>

 

 

 

<asp:Label ID="lblCategoryStatus1" runat="server" SkinID="h6" Text="Test" ></asp:Label

>

 

 

 

</td

>

 

 

 

</tr

>

 

 

 

<tr>

 

 

 

<td

>

 

 

 

<ig:WebDataGrid ID="wdgCategory" runat="server"

 

 

 

AutoGenerateColumns="false" DataSourceID="objCategory" DataKeyFields="CategoryId" Width="350px" >

 

 

 

<Behaviors

>

 

 

 

<ig:Activation/>

 

 

 

<ig:EditingCore Enabled="true" AutoCRUD

="true">

 

 

 

<Behaviors

>

 

 

 

<ig:RowAdding

>

 

 

 

 

<ColumnSettings

>

 

 

 

<ig:RowAddingColumnSetting ColumnKey="CategoryId" ReadOnly="true"

/>

 

 

 

</ColumnSettings

>

 

 

 

<AddNewRowClientEvents

/>

 

 

 

</ig:RowAdding>

 

 

 

 

 

<ig:RowDeleting

/>

 

 

 

 

<ig:CellEditing

>

 

 

 

<ColumnSettings

>

 

 

 

<ig:EditingColumnSetting ColumnKey="CategoryId" ReadOnly="true"

/>

 

 

 

</ColumnSettings

>

 

 

 

</ig:CellEditing

>

 

 

 

</Behaviors

>

 

 

 

</ig:EditingCore

>

 

 

 

 

<ig:ColumnFixing

/>

 

 

 

<ig:ColumnMoving

/>

 

 

 

<ig:ColumnResizing

/>

 

 

 

<ig:Paging PageSize

="5"/>

 

 

 

<ig:Selection CellClickAction="Row" RowSelectType="Multiple" ColumnSelectType

="Multiple"/>

 

 

 

<ig:RowSelectors RowNumbering="true"

/>

 

 

 

 

</Behaviors>

 

 

 

<Columns

>

 

 

 

<ig:BoundDataField DataFieldName="CategoryId" Key="CategoryId" Header-Text="Category Id" Width

="90px"/>

 

 

 

<ig:BoundDataField DataFieldName="Category" Key="Category" Header-Text="Category" Width="150px"

/>

 

 

 

</Columns

>

 

 

 

</ig:WebDataGrid>

 

 

 

</td

>

 

 

 

</tr

>

 

 

 

</table>

 

 

 

</ContentTemplate

>

 

 

 

</asp:UpdatePanel

>

 

 

 

 

<!--#END SNIPPET#-->

 

 

 

<div style="border-left: 0px; padding: 0px; width

: 350px">

 

 

 

<asp:Button ID="btnSaveData" ClientIDMode="Static" runat="server" CssClass="batch-buttons" Text="Save Category"

/>

 

 

 

<!--<asp:Button ID="btnDefaultData" runat="server" CssClass="batch-buttons" Text="Cancel" CommandName="Cancel" /> -->

 

 

 

</div

>

 

 

 

 

 

 

 

<div

>

 

 

 

<table>

 

 

 

<tr

>

 

 

 

<td

>

 

 

 

<asp:Label ID="lblCategory" runat="server" Text="Category" SkinID="h4"></asp:Label> </td

>

 

 

 

<td>

 

 

 

<ig:WebDropDown ID="wddCategory" runat="server" Width="200px" CurrentValue="Select Category"

 

 

 

DropDownContainerWidth="300px" >

 

 

 

 

</ig:WebDropDown

>

 

 

 

</td

>

 

 

 

</tr

>

 

 

 

 

</table

>

 

 

 

</div>

 

 

 

 

</form

>

</

 

 

body>

Thanks,

pufftuff

Parents
  • 49378
    posted

    Hi pufftuff,

    Thank you for posting in the community.

    From what I can see in your code WebDataGrid is inside an updatePanel. I suggest that you try disabling the grid's AJAX in order to check if that makes a difference. In order to investigate this further I would need to know your exact product version. A small working sample illustrating the matter would be greatly appreciated and would help isolate the matter.

Reply Children
No Data