Last post Aug 01, 2017 08:35 AM by Deepak Panchal
Jul 28, 2017 09:42 PMfirstname.lastname@example.org|LINK
For the past two days I have been struggling with a good method of editing a SQL record using both ASP DETAILS VIEW. or FORM VIEW. Both to edit and bind a record they use <EditItemTemplate> and a BIND code routine on the ASP page. But some of my fields
in the record require specific data that would require the user to choose from a dropdown list. I have found integrating the dropdown list as confusing and cumbersome. The problem is I cannot figure out how to integrate <asp:listItem> into a Dropdown with
a bound data.
So here is what I am planning to do that would seem to give me far more control and a more effective method of creating the user experience. I think I will just create a ASP FORM with the ASP Text boxes, and ASP dropdown list. Then on the form load event
in the VB code behind I will read the read the record from the SQL database with the ID that I get from a session variable and populate the asp text boxes and dropdown list with the record data. I will then be able to use validation and dropdown boxes with
no issue. The user then make corrections in the record and clicks on an UPDATE button. The VB code behind the UPDATE button will then do a SQL UPDATE command and update the record based on the record ID that I have stored in the variable and the contents
of the text boxes and dropdown list. This I think will allow me far more control over the look of the form and I will not have the issues with integrating the DROPDOWN list that is Data Bound.
Aug 01, 2017 08:35 AM|Deepak Panchal|LINK
you had asked,"I cannot figure out how to integrate <asp:listItem> into a Dropdown with a bound data. "
you can try to something like below.
<asp:DropDownList ID="drpList" AppendDataBoundItems="true" runat="server"><br/>
<asp:ListItem Text="" Value="" /><br/>
or from code behind
protected void Page_Load(object sender, EventArgs e)
DropDownList1.AppendDataBoundItems = true;
DropDownList1.Items.Insert(0, new ListItem(String.Empty, String.Empty));
DropDownList1.SelectedIndex = 0;