Formview itemupdating c
Bind reads and writes and Eval only reads from the Data Source.Admittedly I hardly ever use binding and Data Sources.After you complete the data source wizard the Form View will have controls added to it for the Item Template, Edit Item Template, and Insert Item Template.It is the Edit Item Template you are interested in.The next step is to change out a Text Box for a Drop Down List in the Edit Item Template and get data into the Drop Down List.
NET view and replace the Customer ID Text Box with a Drop Down List.
Actually this caused an error telling that i cannot declare a datasource property for the dropdownlist in formview.
Then i deleted datasource property and used datasource ID property for the dropdownlist. And for the setting selected value issue, i used formviews itemdatabound event. My sample datatables are as follows : teachers table : PKID | name | lastname | department(int) departments table : PKID | department Name I created my dataaccesslayer using dataset designer and in the presentation layer i created two object datasource configured to get data from teachears and departments table respectively.
The Edit Item Template will contain Text Box controls by default.
The Text Box controls provide basic data entry support for editing a record.The generated markup is as follows : In the code behind i used itemdatabound event of the formview so that i set the selected value for the dropdownlist as follows : (Toggle Plain Text) protected void Form View1_Data Bound(object sender, Event Args e) protected void Form View1_Data Bound(object sender, Event Args e) 'VB 'Use Item Updating method to add the drop down's selected value 'before the data is saved Protected Sub Form View1_Item Updating(By Val sender As Object, By Val e As System.