473,394 Members | 1,802 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,394 software developers and data experts.

Set value in DetailsView edit mode (.net 2)

Hello,

I am trying to change a value when a user goes into edit mode on a
DetailsView control. I am trying to use the following, but can not figure
out how to get to the bound field ("MyBoundField") to set its new value.
Any help with this would be appreciated.

Sub EmployeeDetailView_ModeChanged(ByVal sender As Object, ByVal e As
EventArgs)
Select Case CustomerDetailView.CurrentMode
Case DetailsViewMode.Edit
MyBoundField.value = "some value"
End Select
End Sub

--
Thanks in advance,

sck10
Nov 19 '05 #1
1 4409
Hi Sck10,

Welcome to ASPNET newsgroup.
As for the Accessing TextBoxes of BoundFields in DetailsView when turning
from readonly mode to editing mode, here are some of my suggestions:

For DetailsView, the boundField create the TextBox before it finally
construct the control hierarchy and render out. So at the DetailsView's
ModeChanged event, the TextBoxes (if in edit mode) has not been created ,
we can not access them at that time. IMO, if you do need to access the
Textboxes of boundfield in edit mode, you can consider registering the
DetailsView's PreRender event, at that time the TextBoxes has been created
(if exists ). For example, here is some code snippet which get the
reference to TextBoxes of bound fields when DetailsView turn into Edit mode:

===============
protected void DetailsView1_PreRender(object sender, EventArgs e)
{
if (DetailsView1.CurrentMode == DetailsViewMode.Edit)
{
foreach (DetailsViewRow dvr in DetailsView1.Rows)
{
if (dvr.Cells.Count == 2)
{
Response.Write("<br>" + dvr.Cells[1].Text);
if(dvr.Cells[1].Controls.Count>0)

//this should be the textbox control
Response.Write("<br>" + dvr.Cells[1].Controls[0]);
}
}
}
}
===============

In addition, for get a clear view of the DetailsView's runtime control
structure, you can trun on the asp.net page's Trace so as to view the
control Tree structure which is very helpful. e.g:

<%@ Page Language="C#" AutoEventWireup="true" Trace="true"

Hope helps. Thank you!

Steven Cheng
Microsoft Online Support

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

--------------------
| From: "sck10" <sc***@online.nospam>
| Subject: Set value in DetailsView edit mode (.net 2)
| Date: Wed, 2 Nov 2005 10:57:29 -0600
| Lines: 21
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
| Message-ID: <#3**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 189.202.185.135.in-addr.arpa 135.185.202.189
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:135550
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hello,
|
| I am trying to change a value when a user goes into edit mode on a
| DetailsView control. I am trying to use the following, but can not figure
| out how to get to the bound field ("MyBoundField") to set its new value.
| Any help with this would be appreciated.
|
| Sub EmployeeDetailView_ModeChanged(ByVal sender As Object, ByVal e As
| EventArgs)
| Select Case CustomerDetailView.CurrentMode
| Case DetailsViewMode.Edit
| MyBoundField.value = "some value"
| End Select
| End Sub
|
| --
| Thanks in advance,
|
| sck10
|
|
|

Nov 19 '05 #2

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

Similar topics

2
by: sck10 | last post by:
Hello, I am trying to programically make the following TemplateField ("MyTemplate") visible when the user clicks on the "Edit" Button using the PreRender handle event. My question is, how do...
2
by: clickon | last post by:
I am using ASP.net 2.0 and trying to take advantage of the updated data editing facilities provided through the SQLDataSource control and the DetailsView control. The data is a record from a...
0
by: clickon | last post by:
I want to use an INSERT Query as the value for the UpdateCommand property of an SQL datasource, anyone know if this will actually work ? The reason i want to do it is bacause i am taking values...
2
by: rockdale | last post by:
Hi, I am upgrading my asp.net 1.x to asp.net 2.0. In my page I have a datagrid and a group of textbox, dropdownlist, checkbox... etc. the datagrid and the group of controls are hooked up - when...
0
by: Mike | last post by:
I've a datagrid containing user's information which onselect displays a detailsview control in edit mode I've set-up two template fields to map to (country) and (region) these are dropdownlists...
1
by: Timothy H. Schilbach | last post by:
Hi Everyone, I am having a massive issue trying to get custom data into my DV. What I want to do is sooo simple: 1. I have a single DV on a page 2. I created my own template (see below) 3....
1
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
When I click the "Edit" hyperlink, my DetailsView doesn't enter Edit mode. It will if I set the DefaultMode="Edit". Any thoughts? Thanks. <asp:DetailsView ID="DetailsView1"...
0
by: Andreas Wöckl | last post by:
HI Group! I am really getting crazy with my DetailsView. I have the following code initializing the Page where the DetailsView is in it: If Session("firmaNr") = 0 Then...
0
by: gsauns | last post by:
I have a DetailsView which is inside of a FormView. I lifted this DetailsView straight off another one of my pages, where it was working beautifully. Now I get this endlessly frustrating error...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.