Gridview rowupdating findcontrol textbox

It then retrieves the values from Birth Date and Hire Date textboxes (Text Box1 and Text Box2 respectively). The code then parses these values into Date Time variables and then assigns them back to the textboxes in yyyy-MM-dd format.

If you are not using any data source control or model binding for databinding purpose, you may need to handle the date conversion during update operation also.

Consider, for example, the Employees table from Northwind database. Let's assume that you wish to display these columns in a Grid View so that the user can change these two date values.

The above markup shows the Edit Item Template of the Birth Date column.

The reason for this odd behavior is that the date input type needs date in ISO format (yyyy-MM-dd) if it has to display it correctly. NET dates are MM/dd/yyyy and hence the date-picker fails to show them correctly.

Additionally, if the user accidently hits Update button while the date-pickers weren't having anything selected NULL values will be added to the columns (if null values are allowed for those field).

Alternatively, you can also use Row Data Bound event handler to convert date values from MM/dd/yyyy to yyyy-MM-dd and then assign to the textboxes.

The following code shows how: The Row Data Bound event is raised for each and every row when the Grid View is being databound.

Search for gridview rowupdating findcontrol textbox:

gridview rowupdating findcontrol textbox-1gridview rowupdating findcontrol textbox-59gridview rowupdating findcontrol textbox-69

The above code checks whether the row being bound is editable or not.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “gridview rowupdating findcontrol textbox”