User Profile & Activity

Douglas Badin Member
Page
of 11

Error:

Server Error in '/NewCoServices' Application.


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: 

An unhandled exception was generated during the execution of the current web request. Information regarding the 

origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 


Code:

<%@ Page Language="C#" %>

<%@ Register Assembly="ISNet.WebUI.WebGrid" Namespace="ISNet.WebUI.WebGrid" TagPrefix="ISWebGrid" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>

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

	<ISWebGrid:WebGrid
		ID="PartsDetail_WebGrid"
		runat="server"
		UseDefaultStyle="True"
		DataSourceID="PartsDetail_SQLDataSource"
		Height="250px"
		Width="100%"
	>
		<LayoutSettings
			AllowAddNew="Yes"
			AllowDelete="Yes"
			AllowEdit="Yes"
			AllowSorting="Yes"
			Hierarchical="false"
		>
			<ClientSideEvents
			/>
		</LayoutSettings>
		<RootTable
			DataKeyField="PARTS_DETAIL_ID"
		>
			<Columns>
				<ISWebGrid:WebGridColumn
					Name="PartsOrderNumber_WebGridColumn" 
					DataMember="PARTS_ORDER_NUM"
					DataType="System.Int32"
					Width="100px"
					Visible="false"
				>
				</ISWebGrid:WebGridColumn>
				<ISWebGrid:WebGridColumn
					Name="PartNumber_WebGridColumn"
					DataMember="PART_NUMBER"
					InputRequired="true"
					Width="130px"
				>
				</ISWebGrid:WebGridColumn>
				<ISWebGrid:WebGridColumn
					Name="PartDescription_WebGridColumn"
					DataMember="PART_DESCRIPTION"
					InputRequired="true"
					Width="300px"
				>
				</ISWebGrid:WebGridColumn>
				<ISWebGrid:WebGridColumn
					Name="PartQuantity_WebGridColumn"
					DataMember="QUANTITY"
					DataType="System.Int32"
					InputRequired="true"
					Width="70px"
				>
				</ISWebGrid:WebGridColumn>
				<ISWebGrid:WebGridColumn
					Name="PartPrice_WebGridColumn"
					DataMember="PART_PRICE"
					DataType="System.Decimal"
					InputRequired="true"
					Width="80px"
				>
				</ISWebGrid:WebGridColumn>
			</Columns>
		</RootTable>
	</ISWebGrid:WebGrid>
		
	<asp:SqlDataSource
		ID="PartsDetail_SqlDataSource"
		runat="server"
		ConnectionString='<%$ ConnectionStrings:NewCoAppSample %>'
		SelectCommand="
						SELECT
								PD.PARTS_DETAIL_ID
							,	PD.PARTS_ORDER_NUM
							,	PD.QUANTITY
							,	PD.PART_NUMBER
							,	PD.PART_DESCRIPTION
							,	PD.PART_PRICE
						FROM
							PARTS_DETAIL	PD
						WHERE
							PD.PARTS_ORDER_NUM	= 5
						"
		DeleteCommand="
						DELETE
							FROM PARTS_DETAIL
						WHERE
							PARTS_DETAIL_ID	= @PARTS_DETAIL_ID
						"
		UpdateCommand="
						UPDATE
							PARTS_DETAIL
						SET
							PART_NUMBER			= @PART_NUMBER
						,	PART_DESCRIPTION	= @PART_DESCRIPTION
						,	QUANTITY			= @QUANTITY
						,	PART_PRICE			= @PART_PRICE
						WHERE
							PARTS_DETAIL_ID	= @PARTS_DETAIL_ID
						"
		InsertCommand="
						INSERT INTO
							PARTS_DETAIL
						(
							PARTS_ORDER_NUM
						,	PART_NUMBER
						,	PART_DESCRIPTION
						,	QUANTITY
						,	PART_PRICE
						)
						VALUES
						(
							5
						,	@PART_NUMBER
						,	@PART_DESCRIPTION
						,	@QUANTITY
						,	@PART_PRICE
						)
						"
	>
		<InsertParameters>
			<asp:Parameter Name="QUANTITY" Type="Decimal" />
			<asp:Parameter Name="PART_NUMBER" Type="String" />
			<asp:Parameter Name="PART_DESCRIPTION" Type="String" />
			<asp:Parameter Name="PART_PRICE" Type="Decimal" />
		</InsertParameters>
		<SelectParameters>
		</SelectParameters>
		<UpdateParameters>
			<asp:Parameter Name="QUANTITY" Type="Decimal" />
			<asp:Parameter Name="PART_NUMBER" Type="String" />
			<asp:Parameter Name="PART_DESCRIPTION" Type="String" />
			<asp:Parameter Name="PART_PRICE" Type="Decimal" />
		</UpdateParameters>
	</asp:SqlDataSource>
		
    </div>
    </form>
</body>
</html>

 

Trigger:

CREATE TRIGGER tr_PARTS_DETAIL_Insert
ON 
	PARTS_DETAIL 
FOR INSERT

AS
	
IF @@rowcount < 1 RETURN

BEGIN

	DECLARE @PartsDetialID							INT
	DECLARE @PartsOrderNum							INT

	DECLARE PartsDetailInserts CURSOR FAST_FORWARD FOR
		SELECT 
			I.PARTS_DETAIL_ID
		,	I.PARTS_ORDER_NUM
		FROM 
			inserted	I 


	OPEN PartsDetailInserts

	FETCH NEXT FROM
		PartsDetailInserts
	INTO
		@PartsDetialID
	,	@PartsOrderNum
	    
	WHILE @@FETCH_STATUS = 0
	BEGIN

		UPDATE
			PARTS
		SET
			PART_PRICE_TOTAL	= dbo.fnParts_PartPriceTotal(@PartsOrderNum)
		WHERE
			[PARTS_ORDER#]	= @PartsOrderNum


		FETCH NEXT FROM
			PartsDetailInserts
		INTO
			@PartsDetialID
		,	@PartsOrderNum

	END  

	CLOSE PartsDetailInserts
	
	DEALLOCATE PartsDetailInserts





END

RETURN

Hi,

It works.

Pretty simple with the RootTable.CreateFormula() Method.

Thanks,

Doug

Posted: March 10, 2010 11:59 AM

Hi,

That fixed it.

Thanks,

Doug

I guess you didn't reproduce the problem with the steps from my previous post.

I was describing when the Product Number Value is in the Database and just going into EditMode on the WebCombo leads to the Product Name Value being Set to an Empty String without Changing the Value in the WebCombo.

It is OK to Set the Product Name Value to an Empty String if it is not in the Database but it is NOT OK to Set the Product Name Value to an Empty String it if it is in the Database

STEPS TO REPRODUCE:

You can test it with the instructions from my previous post or try this:

  1. Click on the Product Number Column in a row

    Make Sure it is in Edit Mode and the WebCombo is available.  If this is a new row it should already be in Edit Mode.  If it is an existing row you may need to double click it to get it into Edit Mode
  2. Select "1" from the DropDown
  3. Press the "Tab" Key

    Focus goes to the Product Name Column and "Chai" is populated in it
  4. Press the combination "Shift" + "Tab" Keys

    Focus goes back to the Product Number Column
  5. Press the "Tab" Key

    Focus goes to the Product Name Column and "Chai" is cleared, set to an Empty String

PROBLEM:

"1" is a valid Product Number yet it in the above scenario, in Step 5, the Product Name Column Value is Set to an Empty String.

 

How can this problem be corrected?

Hi,

I found a problem.

  • For an existing row, click on the WebCombo Column to cause it to go into Edit Mode
  • Press the Tab Key

    The Product Name is Deleted

I a guessing this is because the JavaScript is checking to see if a Row is Selected.  Since the Drop Down never occurred, the Load never occurred so a row was never selected.

I do want to blank out the Product Name when the User types in something not in the List, such as "78" or "".

Doug

Hi,

The RebindDataSource() worked.

Thanks,

Doug

Hi,

That seems to be working.  I will do more testing.

This is a lot easier than what I had came up with for when the WebCombo was standalone.

http://www.intersoftpt.com/Community/WebCombo/How-do-I-wait-for-the-DropDown-to-be-loaded-in-the-WebCombo-Client-Side-OnBlur-Event/

I ended up doing a SendCustomRequest so I could monitor it's completion.  I had tried the LoadValue but I think I ran into the problem where the ProductID was not updated.

Thanks,

 

Doug

All times are GMT -5. The time now is 8:37 AM.
Previous Next