473,801 Members | 2,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView ODS and ConvertEmptyStr ingToNull="fals e"

Woundering if anyone else has had issues with
ConvertEmptyStr ingToNull="fals e" ?

I have a custom data class and am passing values to it via an ODS. On my
insert, if the bound text box is empty an empty string or "" is passed to my
data object. On an update, an empty string is converted to null.

The insert does not use the ConvertEmptyStr ingToNull="fals e" property and
works the way I was hoping. Setting this property on the update parameters
in the ODS seems to have no affect.

Thanks for any help or ideas. I really don't want to check for nulls in my
data object for each field.

-Andrew


<asp:ObjectData Source ID="ObjectDataS ourceMain" runat="server"
DeleteMethod="D elete" InsertMethod="I nsert"
OnInserting="Ob jectDataSourceM ain_Inserting"
OnSelected="Obj ectDataSourceMa in_Selected" SelectMethod="S elect"
TypeName="Marke tStreet.Data.It emData" UpdateMethod="U pdate">
<DeleteParamete rs>
<asp:Paramete r Name="itemID" Type="Object" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="itemID" Type="Object" />
<asp:Paramete r Name="itemDescr iption1" Type="String" />
<asp:Paramete r Name="itemDescr iption2" Type="String" />
<asp:Paramete r Name="itemNote" Type="String"
ConvertEmptyStr ingToNull="fals e" />
<asp:Paramete r Name="itemCode" Type="String" />
<asp:Paramete r Name="itemPrice " Type="String" />
</UpdateParameter s>
<InsertParamete rs>
<asp:Paramete r Name="itemDescr iption1" Type="String" />
<asp:Paramete r Name="itemDescr iption2" Type="String" />
<asp:Paramete r Name="itemNote" Type="String" />
<asp:Paramete r Name="itemCode" Type="String" />
<asp:Paramete r Name="itemPrice " Type="String" />
</InsertParameter s>

[DataObjectMetho d(DataObjectMet hodType.Update, true)]
public void Update(object itemID, string itemDescription 1, string
itemDescription 2, string itemNote, string itemCode, string itemPrice)
{

// itemNote is NULL here.

using (SqlConnection cn = new SqlConnection(D ataConnection))
using (SqlCommand cm = new SqlCommand("UPD ATE Item SET
ItemDescription 1=@description1 , ItemDescription 2=@description2 ,
ItemNote=@note, ItemCode=@code, ItemPrice=@pric e WHERE ItemID=@itemID" , cn))
{
cn.Open();

cm.CommandType = CommandType.Tex t;
cm.Parameters.A ddWithValue("@i temID", itemID);
cm.Parameters.A ddWithValue("@d escription1",
itemDescription 1);
cm.Parameters.A ddWithValue("@d escription2",
itemDescription 2);
cm.Parameters.A ddWithValue("@n ote", itemNote);
cm.Parameters.A ddWithValue("@c ode", itemCode);
cm.Parameters.A ddWithValue("@p rice", itemPrice);

cm.ExecuteNonQu ery();

cn.Close();
}
}

Apr 13 '06 #1
1 2432
Hi Andrew,

Thanks you for posting.

As for the ObjectDataSourc e control parameter's ConvertEmptyStr ingToNull
setting problem, it is actually due to the separate
ConvertEmptyStr ingToNull setting for DataSource Control and DataBound
control. For DataSource control(such as objectdatasourc e), each parameter
has the "ConvertEmptySt ringToNull" setting. However, in DataBound control,
like GridView, each DataBoundField( BoundField, TemplateField.. .) also has
such a "ConvertEmptySt ringToNull" property. So for update operation in
GridView, the value first be extracted from GridView's field into
datavalues, then passed to ObjectDataSourc e, so if we want let the
emptystring be perserved, we should also configure the
"ConvertEmptySt ringToNull" on the Field in GridView. e.g:

<asp:BoundFie ld DataField="ID" HeaderText="ID" ReadOnly="True"
ConvertEmptyStr ingToNull="Fals e" />

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Apr 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3893
by: scartin | last post by:
I'm fairly new to working with ASP web controls, and am running into what seems to be a ridiculous problem that I'm hoping will be a breeze for an experienced ASP developer. I have a GridView and a FormView on the same page, where the GridView is visible at page load, and the FormView is set to Edit mode by default, but is hidden on the page. I have the Select link enabled on my GridView, and I use the SelectedIndexChanged event to hide...
1
1977
by: Roy | last post by:
Hey all. Below is the nested syntax on how to make a "codeless" nested gridview embedded within another gridviews templatefield column. Only problem is that it loads slow. REAL SLOW. There has to be a better way. Suggestions anyone? By the way, I'm not opposed to coding, it just seems like this should be easily doable on the aspx side of things. Summary: I'm stuffing the 3 three key fields from each row in the master gridview into...
0
3588
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
1
5375
by: trint | last post by:
i have this in the html view: <asp:TemplateField HeaderText ="Remove?"> <ItemTemplate> <asp:CheckBox ID="removeSelect1" runat="server" /> </ItemTemplate> <HeaderTemplate> </HeaderTemplate> <HeaderStyle ForeColor="White" /> </asp:TemplateField>
3
4869
by: nick chan | last post by:
Hi i run into some difficulties getting rowupdating to fire when clicking Update link/button on gridview I set datasource at runtime, basically a datatable Edit and Cancel works. I don't know why RowUpdating just doesn't fire.
0
1984
by: KeesH | last post by:
Hi, I am quite desperate now because I made a nice webshop with a gridview where the customer is able to update the amount of products (Hostas in my situation) or delete the row. The problem is that every works really fine with this code when customers order approximatelly a maximum of 35 products. What I learned so far is to set the EnableViewState="False" for all the labels that don't need a viewstate. This helped a lot. What can I do...
0
1079
by: hhoang.nl | last post by:
I have a very weird problem with the GridView control. Here is the code: <asp:GridView runat="server" ID="gv" AutoGenerateEditButton="true" AutoGenerateSelectButton="true" AllowPaging="true" AutoGenerateColumns="false"> <Columns> <asp:CheckBoxField HeaderText="Enabled" DataField="Enabled"
0
1083
by: Gilbert Tordeur | last post by:
Hello, As most of my users use a slow WAN I always write aspx pages with EnableViewState="false". However, I remark that the RowCommand and the RowDeleting routines of my GridView are not executed with EnableViewState="false", while they are with EnableViewState="true". Does anybody have a solution ?
2
8192
by: Gilbert Tordeur | last post by:
Hello, As most of my users use a slow WAN I always write aspx pages with EnableViewState="false" to reduce the page size. However, I remark that the RowCommand and the RowDeleting routines of my GridView are not executed with EnableViewState="false", while they are with EnableViewState="true". Does anybody have a solution ?
0
9698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10522
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10298
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10274
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9105
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4263
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2962
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.