.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

PageData passes nulls

Posted By:      Posted Date: October 27, 2010    Points: 0   Category :ASP.Net

Caller to Draw.cshtml

        if (errors == false)
            PageData["Range"] = zoom;
            PageData["StartReal"] = startRe;
            PageData["StartImaginary"] = startIm;
            PageData["StartColor"] = startColor;
            PageData["N"] = N;
            PageData["SizePic"] = sizePic;
            @:<img src="@Href("Draw.cshtml")" />;
Here all variables have a value,

however when arriving in Draw.cshtml the PageData all pass as null.


    var zoom = PageData["Range"];
    var startRe = PageData["StartReal"];
    var startIm = PageData["StartImaginary"];
    var startColor

View Complete Post

More Related Resource Links

Content page control passes as argument to javascript function


Here is the content page:


<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="JavaDynamicCopyValue.aspx.cs" Inherits="JavaDynamicCopyValue" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <script type="text/javascript" >
 function copyValue(input, output )
   ouput.value = input.value;
   return true;
 <asp:TextBox ID="txt1" runat="server" onchange="copyValue(this,document.getElementById('<%=txt2.ClientID%>'))"></asp:TextBox>
    <br />
    <br />
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>


I got a javascript run time error says output is undefined. if I view source of the page, the txt1 markup became:

<input name="ctl00$ContentPlaceHol

Varchar string to int - how to convert empty cells to nulls

Hi, I have a large table from which I want to convert certain columns from varchar to int while loading the table to another table. However, I run into problems when the input column contains empty cells. The SSIS data conversion data flow item can't handle these so I tried the script component. With the script component I can convert these empty cells to zeros but after that I'd need to use SQL update to update the zeros to nulls which in the case of a large table with over 3 million rows takes unnecessarily long. So, is there another way?

dealing with nulls in a Int32.Parse(string) statement

How do I deal with null values in this section it throws errors when they leave the field blank it is a small order form and they don't have too add data to all the fields .   comm.Parameters.Add("@item_9223", System.Data.SqlDbType.Int);                comm.Parameters["@item_9223"].Value = Int32.Parse(txtitem_9223.Text);                comm.Parameters.Add("@item_9129", System.Data.SqlDbType.Int);                comm.Parameters["@item_9129"].Value = Int32.Parse(txtitem_9129.Text);                comm.Parameters.Add("@item_42795", System.Data.SqlDbType.Int);                comm.Parameters["@item_42795"].Value = Int32.Parse(txtitem_42795.Text);                comm.Parameters.Add("@item_30695", System.Data.SqlDbType.Int);                comm.Parameters["@item_30695"].Value = Int3

Importing Data from Excel into SQL Server using SSIS: some datetime values appear as NULLS How to Re

I created a Package in the Business Intelligence studio to Import data from Excel file  into SQL Server 2005 using a Excel Source and a OLE DB Destination that uses a data convertion transformation before it reaches the destination a mjority of the data is copied over. However i am having 2 Issues. 1. In the Date field some of the values appear as Null in SQL Server 2. I need to change the format of the date in Excel from dd/mm/yyyy to mm/dd/yyyy before inserting into SQL Server if Possible. I am not sure of the solution for Ques 1 but i attempted using a script task for #2 It did not work. Please Advice what the best way to proceed Thanks.


Hi, I am querying a column: Column 1 2 3 4 null null query: Select * from table where column != 1 Now , it just ignores null values and returns  2 3 4. I have to query like this to get the null values: select * from table where column != 1 or column is null is there any other way i can query the column to return the null value as well. why it is ignoring the null in the first query ?

pushing 2columns of one table to another table after filtering(eliminating nulls & inserting only ip

hi thankz in advance,i have 2 tables t1 and t2in t1 i have 4 columns from that i want to insert only 2 columns to another table t2 i only want to send data which is in the form of ip adress like( eliminating nulls and other data.plz suggest me is it possible to write a query or i need to do it programetically.thankz a lot..

join help with nulls

Hi,I have 6 tables I want to join and and need to handle a null value when doing an aggregation of certain values.Table 1: Staff - Col: StaffID StaffNameTable 2: SystemUsers: Col: StaffID DepartmentIDTable 3: Bookings Col: BookingID BookedByID(fk for StaffID)Table 4: Transfers Col: TransferID BookingID(fk) BookedBYID(fk StaffID but can be null) 'I didnt set up the tableTable 5: BookingPayments COl: PaymentID BookingID(fk) CommissionTable 6:TransferPayments Col: PaymentID TransferID(fk) CommissionBasically I have to sum  up the commission for each of the staff members that made the booking or transfer.I need the StaffID, Staff Name , sum(commission) and Departmentid. Now here lies the issue all transfers are linked to a booking and the payments are linked to either a transfer or a booking.If it is a transfer booking payment I need to add the commission to the staff member(bookedbyID) in the Transfers table but if this value is null then I have to use the Bookings BookedBYID value, I would also need this to flow onto getting the Staff Name from the Staff Table and the DepartmentID from the SystemUsers table.I have got a query but it misses out the Null valued rows for the Transfers and their payments.Would like some fresh ideas so I will not post my shocking query.Thanks P

inserting one table data to another after filtering nulls and duplicates

hi i have tbl_ip i want to filter nulls and duplicate to my tbl_ipfilter can u suggest me a stored procedure for this. data of tbl_ip is like below . ip NULL NULL NULL

How to Get Attachment from an Infopath Form and Passes it to another infopath form in WorkFlow


Hi ,

how can I set a value inside an Infopath form task control ?

i used the following code but it's not working i don't know why

RequestSubmitted_TaskProperties.ExtendedProperties["attachctrl"] =Request.Attachctrl;


and i have another Issue the OnTaskChanged Event doesn't fires while i was submitting the TaskForm i don't know why

please advice



Filter out nulls in Excel


HI All,


Is there a way to use non empty in excel(which is connected to cube) like the way we use when writing MDX? We have a couple of values that have empty metrics and we wan to filter them out.


Thanks in advance.

How to handle Db nulls


I am retrieving a database object and trying to set the values of the object's fields to various textboxes in my vb.net page.


However, since some of the database fields have null values, I am getting the following error.

System.InvalidOperationException: Nullable object must have a value.

 How do I solve this problem? 

ObjectDataSource InsertParameter always passes 0 to Insert method


I have a FormView and ObjectDataSource nested in a GridView.  Each form requires an ID value from the GridView Row it is on.

To accomplish this, I use the GridViewRow_RowDataBound event, and get the ID I need from the GridView's DataKeys.  I then get a handle on my ObjectDataSource for that row using Row.FindControl(), and assign the ID value to the proper InsertParameter[].DefaultValue.

This all seems to work fine, I can verify the value is retrieved and I get no error on the assignment.  Unfortunately, the value passed to my Insert method is always 0, causing a DB error (foreign key violation, because 0 is not valid).

I'm at my wits end as far as figuring out why this InsertParameter won't keep its assigned value.  If anyone can help, I'd appreciate it.

The RowDataBound code:

protected void gvIndicator_RowDataBound(object sender, GridViewRowEventArgs e)
            if (e.Row.RowType == DataControlRowType.DataRow)
                string strGoalIndicatorID = ((GridView)sender).DataKeys[e.Row.RowIndex]["GoalIndicatorID"].ToString();
                //AppUser u = (AppUser)Session["AppUser"];

SQL Server Express Nulls versus empty strings??



I have a SQL Server column FileLocation which is declared
varchar(150), not null

Some of the values look like nulls to me ..
len(FileLocation) gives zero length

Isnull(ltrim(rtrim(FileLocation)), 'test')

..does not bring back 'test' - why is this?

Do I need a patch for my sql server version? a service pack?


Insert with NULLs


Hello all,

I have a program which has 11 variables. 5 of these can be empty strings which I need to be inserted as NULLS. I have tried to figure out where I am failing in my code without success. I hope someone here might be able to see what I am doing wrong. Many thanks and here is the code:

 private void PostDatatoServer()
            String connectionString = @"Data Source=LUCKYTIGER\SQLEXPRESS;Initial Catalog=John;Integrated Security=True";
            SqlConnection con = new SqlConnection(connectionString);
            textBox1.Text = "Connection made";
            string str = "";
            str += "INSERT INTO Parsed(Date, Gal, Sys, Sl, ST, PN, PlayN, Sym, Rk, All, Rel)";
            str += "VALUES(@Date, @Gal, @Sys, @Sl, @ST, @PN, @PlayN, @Sym, @Rk, @All, @Rel)";
            SqlCommand cmd = new SqlCommand(str, con);
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add(new SqlParameter("@Date", uegParser.strTime));
            cmd.Parameters.Add(new SqlParameter("@Gal", Convert.ToInt16(uegParser.strGalaxyNum)));
            cmd.Parameters.Add(new SqlParameter("@Sys", Convert.ToInt16(uegParser.strSystemNum)));
            cmd.Parameters.Add(new SqlParameter("@Sl", uegParser.intSlot));
            cmd.Parameters.Add(new SqlParameter("@ST", uegParser.intSlotType));

PageData weirdness, works, then doesn not work. Change the 'index' name and it works again


I'm facing a weird issue. I have a page "add.cshtml" in wich I create a PageData object like this:


PageData["myObject"] = new { Message = "some msg", ID = 1, Name = "some name" }

In that same page, I pass the object to a RenderPage:



@RenderPage("form.cshtml", PageData["myObject"])


In "form.cshml", I simply call values like this:


<br />

When I call "add.cshtml", it works, then for some reason, at some point, I get an error stating: "object" does not contain a definition for Message, if I comment the @PageData["myObject"].Message, error occurs on next property.

When this happens, I change "myObject" to another value in both files, and no more compilation error.

Why does this happen?



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend