• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 538
  • Last Modified:

vb.net detailsview change data before update

I have a detailview showing data from an MS SQL 2000 table.  It shows fldtaskname, fldstartdate, and fldclosedate.  In edit mode I have put a dropdown list with the values Yes and No.  If the user selects Yes I want to put todays date in the fldCloseDate, if they select No I want to leave the field unchanged.

How do I intercept the update and convert Yes to todays date, or convert No to null value?

<asp:TemplateField HeaderText="Close" SortExpression="fldCloseDate">
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem Selected="True">No</asp:ListItem>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("fldCloseDate", "{0:dd/MM/yyyy}") %>'></asp:Label>
1 Solution
Create a SelectedIndexChanged event for the dropdownlist2. Set the autopostback property to true. Inside the event, check whether the text in the list is yes or no and set the date accordingly. For example

if dropdownlist2.text="Yes" then
end if
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now