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

DetailsView template field problem

Ram

I'm using detailsview control with a template field which contains a
dropdownlist
I databind the dropdownlist during page load, now the problem is
dropdownlist loses state during postbacks, i looked at the enableviewstate
property to see if viewstate is enabled and it is.

Any ideas!!!

Thanks,
<Ram/>
Dec 1 '05 #1
2 3112
It depends on which control/event caused the postback. If you have the
dropdownlist within an EditItemTemplate then you can get its value during the
processing of the ItemUpdated that is triggered by the DetailsView like this:

void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
DropDownList ddl =
(DropDownList)((System.Web.UI.WebControls.DetailsV iew)sender).FindControl("DropDownList1");
if (ddl != null) //you found the dropdownlist
{
//add your code here
}
}

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Ram" wrote:

I'm using detailsview control with a template field which contains a
dropdownlist
I databind the dropdownlist during page load, now the problem is
dropdownlist loses state during postbacks, i looked at the enableviewstate
property to see if viewstate is enabled and it is.

Any ideas!!!

Thanks,
<Ram/>

Dec 1 '05 #2
Hi Ram,

You should add a check in your page load method for a postback:

if(!IsPostBack)
{
//Bind your data
}

If you don't do this, your ViewState will be reďnitialized during
every page load.

Also make sure that you have unique values in your dropdownlist or it
will return false data from the viewstate.

Regards,
Bart

Dec 1 '05 #3

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

Similar topics

12
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press...
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,...
1
by: vbnetdev | last post by:
I need to customize the DetailsView New record (insert) so that it gets the maximum value of ROWID and adds 1, places that value in the textbox and makes it read only. Also, I have a field...
3
by: chrisn | last post by:
Hi, (Using ASP.Net 2.0) I have a wizard control inside a detailsview control. When I attempt to call the InsertItem method on the DetailsView I get an error "ObjectDataSource...
2
by: K B | last post by:
Hi, Is there ANY WAY to hide a row/field in a DetailsView based on meeting a condition at the ItemCreated or ModeChanging event -- or any other way? There appears not to be, but I was hoping for...
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...
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....
0
by: SAL | last post by:
I have a DetailsView on one of my site's pages that is mis-interpreting a bit field as a text field. On all of the other page's in my site, the DetailsViews show this field as a checkbox but as a...
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration:...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
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,...

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.