473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Readonly bound field returns null in update method

Hello,

I have grid view which can go into edit mode. I have fields one of
which is primary key I dont want to display this field but will use
this field in my update method. If I make the bound column readonly i
get nulls if i set visible to false i get nulls. When visible and not
readonly i get value however I dont want people trying to change
unique ids. Here is some code

<asp:GridView ID="dgMembers" runat="server"
AutoGenerateEditButton="True" AutoGenerateColumns="False" >
<Columns>
<asp:BoundField DataField="TeamMemberID"
NullDisplayText="" ConvertEmptyStringToNull="False"/>
<asp:BoundField DataField="MemberFirstName"
HeaderText="First Name" />
<asp:BoundField DataField="MemberLastName"
HeaderText="Last Name" />
<asp:BoundField DataField="MemberJobTitle" HeaderText="Job
Title" />
<asp:TemplateField HeaderText="Email - Not editable">
<ItemTemplate>
<%#Eval("MemberEmail")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>

</asp:GridView>

my dataasource looks like

<asp:ObjectDataSource ID="dsMembers" runat="server"
SelectMethod="GetAllTeamMembers"
TypeName="TeamMemberController" UpdateMethod="UpdateTeamMember">
<SelectParameters>
<asp:SessionParameter Name="GUID" SessionField="GUID"
Type="String" />
<asp:Parameter DefaultValue="true" Name="AddCaptain"
Type="Boolean" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="TeamMemberID" Type="String"/>
<asp:Parameter Name="MemberFirstName" Type="String" />
<asp:Parameter Name="MemberLastName" Type="String" />
<asp:Parameter Name="MemberJobTitle" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>

when i do this in gridview

<asp:BoundField DataField="TeamMemberID" NullDisplayText=""
ConvertEmptyStringToNull="False" ReadOnly=true/>

I dont get null passed through to update method.

Any ideas anyone?

Regards

Ismail

Mar 6 '07 #1
2 6274
Server controls with Visible=false don't get rendered to the client and
don't come back on postbacks. You should leave Visible=true and hide the
column with css rule display:none.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
"Ismail" <is**********@iassmarts.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hello,

I have grid view which can go into edit mode. I have fields one of
which is primary key I dont want to display this field but will use
this field in my update method. If I make the bound column readonly i
get nulls if i set visible to false i get nulls. When visible and not
readonly i get value however I dont want people trying to change
unique ids. Here is some code

<asp:GridView ID="dgMembers" runat="server"
AutoGenerateEditButton="True" AutoGenerateColumns="False" >
<Columns>
<asp:BoundField DataField="TeamMemberID"
NullDisplayText="" ConvertEmptyStringToNull="False"/>
<asp:BoundField DataField="MemberFirstName"
HeaderText="First Name" />
<asp:BoundField DataField="MemberLastName"
HeaderText="Last Name" />
<asp:BoundField DataField="MemberJobTitle" HeaderText="Job
Title" />
<asp:TemplateField HeaderText="Email - Not editable">
<ItemTemplate>
<%#Eval("MemberEmail")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>

</asp:GridView>

my dataasource looks like

<asp:ObjectDataSource ID="dsMembers" runat="server"
SelectMethod="GetAllTeamMembers"
TypeName="TeamMemberController" UpdateMethod="UpdateTeamMember">
<SelectParameters>
<asp:SessionParameter Name="GUID" SessionField="GUID"
Type="String" />
<asp:Parameter DefaultValue="true" Name="AddCaptain"
Type="Boolean" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="TeamMemberID" Type="String"/>
<asp:Parameter Name="MemberFirstName" Type="String" />
<asp:Parameter Name="MemberLastName" Type="String" />
<asp:Parameter Name="MemberJobTitle" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>

when i do this in gridview

<asp:BoundField DataField="TeamMemberID" NullDisplayText=""
ConvertEmptyStringToNull="False" ReadOnly=true/>

I dont get null passed through to update method.

Any ideas anyone?

Regards

Ismail

Mar 6 '07 #2
Eliyahu,

Many thanks for this.

Regards

Ismail

Mar 6 '07 #3

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

Similar topics

2
by: WhiskyRomeo | last post by:
I have a bound textbox (bindings are set at design time) to a dataset column. Sometimes the value of this textbox must be set so that the underlying database field gets updated to null when using...
3
by: Bill Clark | last post by:
I have about 20,000 records pulled from Excel that I need to update. What I need to do is run an update query that bascially says: If a field is null, update it with the previous record value of...
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
6
by: JohnR | last post by:
I have a table with 1 row which is used to hold some application wide items (one item per field, hence I only need 1 row). I want to bind one of the fields to a textbox. After setting up the...
13
by: nyt | last post by:
I have a problem of number and text field. I got the database file(mdb) that contains many combo boxes used and its list values are created by "value list" For eg field Field name= 'furniture'...
1
by: Raja | last post by:
Hi Everybody Just playing with ObjectDataSource and noticed the following. I have a Gridview which binds to a ObjectDataSource. ObjectDataSource gets data from a typed dataset created with VWD. In...
1
by: Pao | last post by:
I have a formview bounded to an objectdatasource. All ok but I have some trouble with a checkbox: when I am in update mode and I update the record, this field is never updated (no errors thrown)....
0
by: Mike | last post by:
So here's the situation (.NET 2.0 btw): I have a form, and on this form is a textbox among many other databound controls. The textbox is bound to a field in a data table via the Text property. ...
1
BeemerBiker
by: BeemerBiker | last post by:
Using GridView and SqlDataSource I found that an index field defaults to "ReadOnly=True" and I have to change it to False and then hide it before my sql UPDATE command works. This seems awkward and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.