473,401 Members | 2,139 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,401 software developers and data experts.

Setting control values in DetailsView

Hello,

I have a GridView that list all the employees in our group. My select
button (link) when clicked will open a DetailsView control of the employee
selected. I have one BoundField in the form that I want to fill in
programatically ("UpdatedBy"). So when the user selects the "edit" link,
the field is pre-populated with this value. This value needs to submitted
when the user clicks "update". Any help with this would be greatly
appreciated...

<asp:DetailsView ID="dvDetail"
....

<Fields>
<asp:BoundField DataField="UpdatedBy" HeaderText="Updated By"
ReadOnly="true" SortExpression="UpdatedBy" />
</Fields>
I am using the following to set the value, but getting the error:

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.
Protected Sub dvDetail_ModeChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles dvDetail.ModeChanged
Dim txtUpdatedBy As TextBox = CType(Me.dvDetail.FindControl("UpdatedBy"),
TextBox)
txtUpdatedBy.Text = "sckeels"

End Sub
Nov 19 '05 #1
1 3222
Just add a new <asp:Parameter> to your ObjectDataSource or SqlDataSource
and then set the parameter value in the DataSOurce's Updating event. The
event args parameter to the event will give you access to the parameters
where you can set the value from User.Identity.Name. I just posted on this
recently:

http://forums.asp.net/1041066/ShowPost.aspx

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hello,

I have a GridView that list all the employees in our group. My select
button (link) when clicked will open a DetailsView control of the
employee selected. I have one BoundField in the form that I want to
fill in programatically ("UpdatedBy"). So when the user selects the
"edit" link, the field is pre-populated with this value. This value
needs to submitted when the user clicks "update". Any help with this
would be greatly appreciated...

<asp:DetailsView ID="dvDetail"
...
<Fields>
<asp:BoundField DataField="UpdatedBy" HeaderText="Updated By"
ReadOnly="true" SortExpression="UpdatedBy" />
</Fields>
I am using the following to set the value, but getting the error:

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.
Protected Sub dvDetail_ModeChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles dvDetail.ModeChanged
Dim txtUpdatedBy As TextBox =
CType(Me.dvDetail.FindControl("UpdatedBy"),
TextBox)
txtUpdatedBy.Text = "sckeels"
End Sub


Nov 19 '05 #2

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

Similar topics

5
by: sck10 | last post by:
Hello, I am using the code below to set the values of a DetailsView template field using FindControl. My question is how would you find a control if its a Boundfield control? For example,...
3
by: stuart.d.jones | last post by:
Hi, I have a DetailsView control bound to a SqlDataSource. I've got everything working nearly as I want, but here's my problem. I have a table which has a Guid as a Primary Key, and a VarChar...
0
by: Seok Bee | last post by:
Dear Experts, In my web application, I have a Master/Detail display of records using Gridview and DetailsView controls. Whenever, I made a selection of a record from the Gridview control, the...
0
by: Marek | last post by:
I have DetialsView control and DropDownList control on the same page. I use DropDownList.SelectedVlue as key for DetailsView control. I use SELECT ... FROM table WHERE id_kont = @id_kont where...
1
by: Jim McGivney | last post by:
Using VWD I have an aspx page with a GridView and DetailsView controls, each using a different AccessDataSource. The DetailsView is displayed with appropriate data when the user selects one of the...
2
by: Ben | last post by:
Hi, In the code-behind, i can refer to the dropdownlist defined in the aspx file with this (e.g.) dropdownlist1.sekectedvalue = ... but why can i not refer to the label defined in the...
0
by: tom c | last post by:
I am going through "Walkthrough: Editing and Inserting Data in Web Pages with the DetailsView Web Server Control" found at http://msdn2.microsoft.com/en-us/library/sdba1d59.aspx I am using...
0
by: miketayloruk | last post by:
I'm using a detailsview control that I want to use to insert data to a table. One of the fields is a date field and I want that to default to todays date. In classic asp I would do it like this: ...
3
by: =?Utf-8?B?QW5nZWw=?= | last post by:
I seem to understand how the control works as long as I mated to SqlDataSource or ObjDataSource it works fine. But I do not want to flatten my design in this manner. I am interested in how I can...
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
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,...
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
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,...
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.