|
Does this help?
Data controls support a variety of ways to handle null or missing data. To begin with, the GridView, FormView, and DetailsView all support an EmptyDataText or EmptyDataTemplate property that you can use to specify a rendering for the control when the data source returns no rows of data. Only one of EmptyDataText and EmptyData needs to be set (EmptyDataTemplate overrides when both are set). You can also specify a ConvertEmptyStringToNull property on BoundFields or data source parameter objects to specify that String.Empty values posted from the client should be converted to null before invoking the associated data source operation. ObjectDataSource also supports a ConvertNullToDbNull property that can be set to true when the associated method expects DbNull parameters instead of null (the TableAdapter classes in a Visual Studio DataSet have this requirement). You can also specify a NullDisplayText property on BoundField to specify a value for the field to display when the field value from the data source is returned as null. If this value is not changed during edit mode, the value will roundtrip as null back to the data source during an Update operation. Lastly, you can also specify a DefaultValue property on data source parameters to specify a default value for the parameter when the parameter value passed is null. These properties can a chaining effect, for example if both ConvertEmptyStringToNull and DefaultValue are set, a String.Empty value will first be converted to null and subsequently to the default value.
But since your objects receieve null they would be defines as object. and you would think that it would just create the object type and be okay.
Hope that helps,
Nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Nick,
I appreciate your comments, however, since this is a FormView control, I cannot use BoundFields, which are the ones with the helpful EmptyDataText and ConvertEmptyStringToNull properties. These properties are unavailable on TextBox, FormView, and ObjectDataSource controls. BoundFields can only be used in GridView, DetailView, and DataList controls. Since no null values are being sent up to my object (using two-way binding), I have to handle empty text boxes differently. My properties include String, nullable DateTime, nullable Integer, and nullable Decimal types. Therefore, DBNull is irrelevant.
Wait a minute! I've got an idea! I'm going to try setting the ODS flag, ConvertNullToDBNull, to true and see if it sends empty text boxes as DBNull, since it won't send null. If so, I can simply catch DBNulls in my properties' set property bag and just handle it as a null value from there!
I'll let you know if it works.
Thanks,
Joel
|
|
|
|
|
yeah. I want to test this out also. It seems ignorant to have an object source control and not send null.
-- modified at 17:20 Friday 28th July, 2006
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
And I would also think that you can set the UpdateMethod to call a custom update method to override the update pattern used.
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
There are two solutions depending on whether you specify parameters or pass objects.
If you specify parameters to ODS - it's pretty simple:
void ItemUpdatingProcessor(ObjectDataSource o,FormViewUpdateEventArgs e)
{
foreach (Parameter param in o.UpdateParameters)
{
if (e.NewValues[param.Name] != null && e.NewValues[param.Name].ToString() == string.Empty)
{
if ((param.Type == TypeCode.Decimal || param.Type == TypeCode.Double ||
param.Type == TypeCode.Int32 || param.Type == TypeCode.Byte ||
param.Type == TypeCode.Single || param.Type == TypeCode.DateTime ||
param.Type == TypeCode.Boolean) &&
param.ConvertEmptyStringToNull == true &&
(param.Direction == System.Data.ParameterDirection.Input ||param.Direction == System.Data.ParameterDirection.InputOutput))
{
e.NewValues[param.Name] = null;
}
}
}
}
If you are passing objects, then custom method:
protected void FixItemUpdating(string[] ignoredList, FormViewUpdateEventArgs e)
{
foreach (var key in e.NewValues.Keys)
{
if (ignoredList.Contains(key))
continue;
if (e.NewValues[key] != null && e.NewValues[key].ToString() == string.Empty)
{
e.NewValues[key] = null;
}
}
}
And "ignoredList" - list of fields that allow empty strings and not allow nulls ( ended up empty for my projects, but you just never know.
|
|
|
|
|
Hi,
Can anyone tell me how to retreive the SelectedValue from a
RadioButtonList, using javavscript.
I need to show it in alert box.
Thanx
nikesh
|
|
|
|
|
Hi,
Example,Get value from Radion Button
it will alert:
Hi ASP.NET
,,,,,,,,,,,,,,,,,,,
Hy Chanhan
|
|
|
|
|
Probably you are looking for this:
http://www.thescripts.com/forum/thread448965.html
Best Regards,
Apurva Kaushal
|
|
|
|
|
I wish I had some demo to refer on how to insert new rows to a gridview thus updating that database. C#.
thanks in advance. Much appreciated.
|
|
|
|
|
|
|
Hi,
I am student of MS. Got a project to do in Distributed Systems. I want to create the mobile agent in .NET Framework. I have never worked on such application before. Can anyone plz tell me the information how should i start my work. Some articles which will help in implementing the agent.I will be very thankful
|
|
|
|
|
|
dear All,
i h a web application which i used to run from my VS 2005 and it generate the following address
http://localhost:1027/UPMS/Login.aspx
can any one tell ,me how i can access this from other PC as i give this address it does not if any one of u help me in this regard i will be gr8full to him
i also publish the site but it give many error
is publiushing a site is only solution or i can use some different methods
thanks in advance
Regards
|
|
|
|
|
The built-in web development server only services the local request, you cannot use it to process the remote request. If you want, you'll need to run your application in the IIS.
What error do you get when publishing your web site? In addition to the Publish menu item, you can use the command line tool aspnet_compiler.exe to precompile your web site.
|
|
|
|
|
thanks for ur kind respose i will send u error occur after i have done this
|
|
|
|
|
insted of localhost put your machines ip.
for example http://199.88.88.99:1027/UPMS/Login.aspx
to know your machine's ip do as below [on windows 2000]
go to command prompt and type "ipconfig" it will show you the IP Address.
now you or any one else can access it form other pc.
CA Keer.
|
|
|
|
|
Hi,
I have uploaded my project to a Web Hosting Server that doesn't provide Crystal Report...
What is the best way to create reports other than using Crystal Report?
I am too late but i will never give up
|
|
|
|
|
If they don't provide, can you deploy the required assemblies seperately?
In addition, you may also consider using another third party component like ComponentOne WebReports, XtraReport ....
|
|
|
|
|
I am happy to talk to you again...
What do you mean by seperately?I mean how could I deploy the crystal report assemblies separately and why?
I have used the Visual Studio.net crystal Report in my Project and then I uploaded the whole Project (to update the Project on the web).
I am too late but i will never give up
|
|
|
|
|
By this I mean you can choose to deploy the assemlies required to run the report in the bin folder of your application.
|
|
|
|
|
We recently upgraded to VS2005 and .NET 2.0. I was running one project earlier with no issues. I tried to open a second project and got the following error:
"Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version = 2.0.0.0, Culture.... failed.' "
The program works fine on my boss' machine. Since the other program works I don't think I installed anything incorrectly. Any ideas on how to fix?
Thanks!
|
|
|
|
|
check your users. your permissions are incorrect on that file
are you part of the debuggers group?
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Hi,
I got this error when I define
Dim htmlwrite As System.Web.UI.HtmlTextWriter
htmlwrite = System.Web.UI.HtmlTextWriter.Null
in the ASP.net code behind.
But if I take the second line out, it gives me another error message "Object not defined"
Basically I just want to open Excel file from ASP page or be able to open Excel page from Explorer. It works fine in ASP, but not working in ASP.NET.
Anyone can help?
Thanks advanced
Dina
Dina
|
|
|
|
|
why would you set it to null?
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|