Web Forms :: DropDownList Control Spawns New Entry Form
Aug 26, 2010
I have a form written in C# with a SQL database to hold the data. At the end of the form, there is a DropDownList control that is blank upon the initial entry. If a user selects anything in that drop down box, upon saving the form, a new form with the same format will be created and the last form will be locked for editing. I have no idea on how to implement this or how to start on this.I'm kinda new to ASP.NET so bare with me please.
After I developed the system by usin vs2008 , my supervisor asked me to develop form in the interface so they can enter information about projects as(project code,project title, country,sector,year) to the database with out dealing with the database in the backend .. so how can i develop it because i am still new to the vs.
I thought this would be very simple but I can't get it. I have a dropdownlist bound to a datasource in order to produce a list of items. At the top of the ddl, I want a 'NEW ITEM' entry. It's not showing up.
In my project requirement user wants to enter a manual entry if they can not find an item in the drop down list.
Right now what I am doing is:
I set the dropdown list autopost back true and on selectedchanged event I am hiding the drop down list and showing a text box to enter a manual entry...
This is working perfect and no problems..
but the drop down list needs to change to a text box on only selecting a "unknown" option in the list...all other list items are doing unnecessary post back to the server with no use...
I am writing an application that collects Customer Complaints and stores them into a database. I want to keep it simple so that the Managers without much web knowledge can use it. This is how my Entry Form works. The Manager selects the name and id of the staff by choosing a location. This loads ids and names of the Staff in that location from the database. Then the Manager rates the complaint based on the severity and enters the comments. I was able to use Session objects to get all these values from the Entry page to the Confirmation page so the Managers can check again. This is where it gets tricky. If there is a correction they have to make by trying to go back to the Entry page, the values are lost (esp. Drop-down ones).
I have several text boxes in an ASP.NET Web Form. I want to ensure that users are not entering HTML into those text boxes. However, I'm not sure how to prevent HTML from being entered. Because of this, I decided that I want to only allow alphanumeric characters, spaces, exclamation point, sharp sign, dollar signs, percentage signs, carets, stars, and left and right parenthesis. I'm omitting the ampersand because I do not want them entering something like "<script&rt;..."
The problem: I have a data entry form. I would like to save the data without page roundtrip or UpdatePanels.The solution: - the 'Save' button calls a javascript function which serialize all the fields content (client side)- the javascript function calls a web method (server side)- the web method deserialize the data and save it to the database.
While converting a desktop application to a web app, I've run across my ignorance when attempting to implement a multi-column data entry form using CSS. I'm resolved to avoid using tables for this type of thing, and while I found a good reference to laying out a data entry form, I can find nothing that applies to multiple-column layouts like this one:
I have 2 dropdowns on my page, i can select from both and complete the other text fields on my form and click my button to submit. But when i receive the email, i get everything from the form, except that the drop down values are coming across as the default value of "0"
Here is my dropdownlist code i have on my page_load to bind them with data when they arrive at the page.
[Code]....
And for the email portion, i am using the selectedvalue as seen below. Thats all i have on the page.. very simple, but only the drop downs are not passing in the email.
ddlCategory.SelectedValue.ToString() and ddlPriority.SelectedValue.ToString()
I've got my validation wired up through my Service layer, and my Birthdate property looks like this.
[Code]....
The client side validation works properly if I input something like `12/12/1990` but when the form is submitted, the server side validation trips and I'm told the entry is invalid. I'm using the jQuery-UI Datepicker to input the date, however when I disable the datepicker, the problem persists.Am I missing something here? I thought the client side and server side would be the same thing.If I remove
[Code]....
Then the form submits. It's obviously something to do with the Regex.
Hello all i have this little issue getting this to work, i have a dropdownlist in asp.net inside a formview and jquery cant find the control im guessing because its inside a form, this is what i got and it works on another page without a formviewi get this errorName 'Country' is not declared
i friends i am having two forms say form a and formb and having two panels in formb and i want to show this panels from forma based on some condition and the code which i am using is
Dim capfrmobj As New CaptureForm capfrmobj.panelvf.Visible = True capfrmobj.pnlc.Visible = False capfrmobj.pnlnc.Visible = False
I had use a combox to let user select staff name and then it will automatically retrive the responsible recommending officer and approving officer to display in other 2 dropdownlist.
my code works fine but when user select staff name each time, the page will reload once to refresh the dropdownlist.
user complaint and don't want the page reload every time, how can i disable the postback? I need to use ajax?
i have a multiline textbox on the form for the user to enter some description. On its OnTextChnaged event, i m using the text in the textbox and populate a dropdownlist with some values.
the textbox's html readd somthing like this
[Code]....
here ddlIndex is the dropdownlist to be populated.
i was wondering if i can use a javascript fucntion to do this?
i dont want the page to go back to the server to populate the ddlist, which does take a considerable time.
how to use a javascript function to achieve this functionality ..
i am using html input fields for inserting data to db e.g.:
<input type="text" runat="server" ClientIDMode="Static" id="StreetNo" class="form-control input-mask-phone"/> and a submit button for submitting all data :
also i am using an update panel to trigger this button click event ( to avoid postbacks and page refreshing ) . i want to clear out all my fields after submition of data , but it won't happens , even i tried on submit_click's event also , i did :
/// after submittion StreetNo.Value = string.Empty;
I do some stuff with dynamic DropDownLists. A choice at one level makes the next level appear and so on.
When I open up an old report for editing, the first level is not editable so I set that DropDownList to Enabled=false (still dynamically in code).
My problem is that when I press save (a LinkButton) I first come to my OnInit as usual and check the Page.Request.Form for my DropDownLists, but then the first list is not represented.
But if I change one of the lists when editing, a postback is made, then there is no problem at all with the Page.Request.Form, the first list is there all the time.
Is there some fundamental difference with causing a PostBack from a LinkButton vs a Dynamically Added DropDownList?
I have a webForm which host a gridview and a formview. The formview is used for showing/editing a record which the user Select from the gridview.
In the formview Edit template I used DropDownList controls with
SelectedValue='<% bind("datafield")%>'
for enabling the user easier interface. A few of the DropDownList controls need to have a list of 100 items and I want to load the items from code behind and not from the aspx.
I tried to update the DDL's from FormView.Load, FormView.ModeChanging, FormView.PreRender but nothing I am getting an error like this:
[code]....
How do I load the DropDownList controls with items BEFORE the form databinding occurs.
See what happens when you answer my questions! I come back! No good deed goes unpunished. I've built an Update form where my visitor can update data in dbase. I have a formview with several dropdown lists; none of which will update the table (all the textboxes, checkboxes and even Ajax enabled calendar work just fine). In the form below, visitor selects a CareerCluster from the ddl. Upon postback, the next ddl (pathwayListBox) populates with related data using the CareerCluster.selectedvalue in a query. At the same time, tsaOrgsDropDownList is also populated based upon the first ddl (CareerCluster).
When user selects from the tsaOrgsDropDownList the final ddl (tsaDropDownList) is populated. All this various selecting/populating works just fine on the form. The problem is: Nothing is updated to the table upon clicking the Update button. All other form fields do post as their supposed to except, I have other ddls on the page that are not related to the above series and they won't post either. My thought is that somehow, this is related to the postbacking going on. That posting back is overwriting the selectedValues with null or something.
<asp:FormView ID="courseUpdateFormView" runat="server" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" DataKeyNames="CTECourseID" DataSourceID="formviewSqlDataSource" Width="715px"> <FooterStyle BackColor="#C6C3C6" ForeColor="Black" /> <RowStyle BackColor="#DEDFDE" ForeColor="Black" /> <EditItemTemplate> <table align="center" width="700" border="1" cellpadding="10" cellspacing="2" bgcolor="White"> <%--A whole bunch of textboxes goes here--%> <tr> <td bgcolor="#dadada"> <strong>Number of HS Credits:</strong> <span>(Standards-based districts use the <em>Other</em> form field.)</span> </td> <td bgcolor="#FCCCCC"> <span><font color="red">Note: you must reselect HS Credits from the list or enter Other credits in the form field provided.</font></span><br /> <asp:DropDownList ID="numHSCreditsDropDownList" runat="server" TabIndex="3" ToolTip="Standards Based districts us the Other form field." ValidationGroup="HSCredits" AppendDataBoundItems="True" OnSelectedIndexChanged="numHSCreditsDropDownList_SelectedIndexChanged"> <asp:ListItem Selected="True" Value="0">--Choose One--</asp:ListItem> <asp:ListItem>0.5</asp:ListItem> <asp:ListItem>1.0</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td bgcolor="#dadada"> <strong>Career Cluster:</strong> </td> <td bgcolor="#FCCCCC"> <span><font color="red">Note: you must reselect Career Cluster from the list.</font></span><br /> <asp:DropDownList ID="careerCluster" runat="server" AutoPostBack="True" TabIndex="4"> <asp:ListItem Selected="True" Value="0">--Choose One--</asp:ListItem> <asp:ListItem Value="1">Agriculture, Food & Natural Resources</asp:ListItem> <asp:ListItem Value="2">Architecture & Construction</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td bgcolor="#dadada"> <strong>Pathways:</strong> <span>(Pathway as defined in the Cluster/Pathway model.)</span> </td> <td bgcolor="#FCCCCC"> <span><font color="red">Note: you must reselect Course Pathway from the list or enter Other Pathway in the form field provided.</font></span><br /> <asp:ListBox ID="pathwayListBox" runat="server" DataSourceID="CTECourses" DataTextField="ClusterPathway" DataValueField="ClusterPathway" SelectionMode="Multiple" Style="margin-left: 0px" TabIndex="5" Rows="3"> <asp:ListItem Selected="True" Value="0">--Choose One--</asp:ListItem> </asp:ListBox> <asp:SqlDataSource ID="CTECourses" runat="server" ConnectionString="<%$ ConnectionStrings:CareerTechEducationConnectionString %>" SelectCommand="SELECT [ClusterName], [ClusterPathwayID], [ClusterPathway], [ClusterCode] FROM [lkClustersPathways] WHERE ([ClusterCode] = @ClusterCode)"> <SelectParameters> <asp:ControlParameter ControlID="careerCluster" Name="ClusterCode" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> </td> </tr> <tr> <td align="center" bgcolor="#4A3C8C" colspan="2"> <asp:Label ID="occupationalStandardsLabel" runat="server" Font-Bold="True" ForeColor="White" Text="Occupational Standards"></asp:Label> </td> </tr> <tr> <td bgcolor="#dadada"> <strong>Source of Occupational Standards:</strong> </td> <td bgcolor="#FCCCCC"> <span><font color="red">Note: you must reselect Source of Occupational Standards from the list or enter Other Source of Occupational Standards in the form field provided.</font></span><br /> <asp:DropDownList ID="tsaOrgsDropDownList" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource3" DataTextField="TSAOrganization" DataValueField="TSAOrgID"> <asp:ListItem Selected="True">--Choose One--</asp:ListItem> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:CareerTechEducationConnectionString %>" SelectCommand="SELECT [TSAOrgID], [TSAOrganization] FROM [lkTSAOrgs] WHERE ([TSAClusterID] = @TSAClusterID)"> <SelectParameters> <asp:ControlParameter ControlID="careerCluster" Name="TSAClusterID" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> </td> </tr> <%--A whole bunch of textboxes, checkboxes and other stuff goes here--%> <tr> <td bgcolor="#dadada"> <strong>What is the Summative Assessment (Technical Skills Assessment) for this course:?</strong> </td> <td bgcolor="#FCCCCC"> <span><font color="red">Note: you must reselect Summative Assessment from the list or enter Other Summative Assessment in the form field provided.</font></span><br /> <asp:DropDownList ID="tsaDropDownList" runat="server" AutoPostBack="false" DataSourceID="TSAs" DataTextField="TSA" DataValueField="TSAID" Width="300"> </asp:DropDownList> <asp:SqlDataSource ID="TSAs" runat="server" ConnectionString="<%$ ConnectionStrings:CareerTechEducationConnectionString %>" SelectCommand="SELECT [TSAID], [TSA] FROM [lkTSAs] WHERE ([TSAOrgID] = @TSAOrgID)"> <SelectParameters> <asp:ControlParameter ControlID="tsaOrgsDropDownList" Name="TSAOrgID" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> </td> </tr> <%--A whole bunch of textboxes goes here--%> <tr> <td align="center" bgcolor="#dadada"> <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" /> <br /> <span><font color="maroon">* All fields except the Tech Prep Information are required.</font></span></div> </td> <td align="center" bgcolor="#dadada"> <asp:Button ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> </td> </tr> </tr> </table> </EditItemTemplate> </asp:FormView> <asp:SqlDataSource ID="formviewSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:CareerTechEducationConnectionString %>" SelectCommand="SELECT * FROM tblCTECourses WHERE (CTECourseID = @CTECourseID)" UpdateCommand="UPDATE tblCTECourses SET HSCredits = @HSCredits, CareerCluster = @CareerCluster, Pathways = @Pathways, TSAOrgs = @TSAOrgs, TSA = @TSA, LastUpdate = GETDATE() WHERE (CTECourseID = @CTECourseID)"> <SelectParameters> <asp:SessionParameter Name="CTECourseID" SessionField="CTECourseID" Type="Int32" /> </SelectParameters> <UpdateParameters> <asp:FormParameter FormField="numHSCreditsDropDownList" Name="HSCredits" Type="String" /> <asp:FormParameter FormField="HSCreditsOtherTextBox" Name="HSCreditsOther" Type="String" /> <asp:FormParameter FormField="careerCluster" Name="CareerCluster" Type="Int32" /> <asp:FormParameter FormField="pathwayListBox" Name="Pathways" Type="String" /> <asp:FormParameter FormField="tsaOrgsDropDownList" Name="TSAOrgs" Type="Int32" /> <asp:FormParameter FormField="tsaDropDownList" Name="TSA" Type="String" /> <asp:FormParameter FormField="TSAOtherTextBox" Name="TSAOther" Type="String" /> </UpdateParameters> </asp:SqlDataSource>
In the codebehind I've tried to set selectedvalue to session variable upon selected index changed like this:
Protected Sub numHSCreditsDropDownList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Session("HSCredit") = DirectCast(courseUpdateFormView.FindControl("numHSCreditsDropDownList"), DropDownList).SelectedValue End Sub
I have a formview that has several dropdownlists in the EditItemTemplate. Some of the dropdownlists are added using placeholders. I can add and populate their listitems without any problem. But when I update the record, none of the controls can be found--even though when I look at the page source they are there. I first strated out using asp:ControlParameter in my sqldatasource updateparameters, but even referencing the control as myform$mycontrol did nothing. So then I moved to code behind on the sqldatasource.updating event (code is attached). The only controls I cannot seem to bind to the update are those added via the placeholder.
[Code]....
The item at the dim statement is not an item added using a placeholder and does not get a null reference exception (I used that to prove during debbugging that I wasn't losing my mind)--however, all the items being used to get the parameter values are getting null reference exceptions and are added via placeholders. Here is the code I'm using to set up the dropdownlists:
[Code]....
how to get the value of these controls so they can be used in my update?