MVC :: Error After Clicking "Save" After Changing The Country In The Drop Down List Box?
May 25, 2010
To any [compassionate] fellow coders:
I'm at Step 6 in the NerdDinner tutorial. It runs fine until I put in the code beginning in Step 6. I add...
ViewData["Countries"] = new SelectList(PhoneValidator.Countries, dinner.Country);
...in the DinnerController.cs file. I've already found where PhoneValidator.AllCountries should be PhoneValidator.Countries, so that's fixed. But when I run the app and select a country from the new dropdown list...
<p>
<label for="Country">Country:</label>
<%= Html.DropDownList("Country", ViewData["Countries"] as SelectList) %> [code]...
I have a dropdown list in my page which can load country list from a SQL database table. Now, I want to choose a country from that drop down list and If I click on the go button, then I want another query which can compare the country name(which I have selected) with another table and load the other necessary info from that table. If I specify the country name on the SQL command , then the data loads nicely(
<asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>" ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>" SelectCommand="SELECT [Zone_Name], [Card] FROM [Rates] WHERE ([Zone_Name] LIKE 'Canada%')"> [code]...
i have one dropdownlist in the gridview. i have to load that dropdownlist when that page is loaded. dropdownlist should contain the country list from country table
I have a Dress Version Table with Colums UK, EU, USA.
Also a Dress Size table which has a VersionId Column corresponding to the Version Table
On my aspx, i have two drop down lists. DD1 is binded to an objectdatasource which
has a select Method to the DAL and retrives the 3 Verions.
DD2 has Get DressSize by Version Method with a Select Parameter which is the DD1 selected Value.
I have wrapped the above in an update panel and the full code is below.
This works but I wonder if there is a better way of doing this?? I also have a probem in that the Dropdowns are in a panel that is within a modal pop up extender. When the dropdowns post back the whole panel disappears. Not sure why??
I have a drop down list that has the initials of about 12 of our sales guys.How can I make it so that when they select their initials from the list, the next drop down list only shows their customers.In my database there is a column for customer name and salesman.
I have already stored value of author id in list item value while page loads. but when I change index of drop down list to view author information error is shown. I tried to debug using check points and it seems Sqlreader isn't reading database second time.
Clicking the label of a drop down list, re-sets the selected value to the first item in the list. This has a history of causing data entry problems when users accidently click on the label.
In the below example ddlContactType has a selected value as 'PRIMARY' and whenever i click on the lblContactType Text, the dropdown box Selected value is changing to "Select One" Text.
How to prevent this one. It should be on PRIMARY Only.
How can I have 2 Cascading Drop Down Lists for the same Drop Down List?here is my problemi have 3 drop down lists read from database1- Schools List 2- Classes List3- Teachers ListEvery School will have more than 1 Class and more than 1 TeacherWhat I want is when user select a School from Schools Drop Down List then BOTH (Classes and Teachers) should be refreshed based on the School Drop Down List
I have a webservice that a developer can use to create a user account, apart of the create user account form, it requires an input of the user's "Postal Address"The Postal address has "Country State Id"Normally, I would provide a list for everything else, but when it comes to country state list it contains thousands and thousands of states/regions and its too much to list in a API specification document. So my question is, 1) do you create a web service for the developer to retrieve the country state id? or 2) provide the developer with a database file, with the list of country state id?
In My project I have DoupDownList(ddl). In my ddl in need to bind country names along With Country Flag..So Can Any One Help Me In thi issue...Country Name And Country Flag Bouth i need to Bind in my ddl
The task is this: Create custom AJAX method with option to call server side ASPX page and predefined Web Service: a.) Get all cities from ASPX page by given Country Code. For ex. send country code "US" to get a result of a unknown number of cities such as "Washington", "New York", "Houston" etc. with their corresponded ZIP codes (1000, 1100, 1200 etc); b.) Call a web service, posting ZIP code which returns does the code represent palindrome string (A number that reads the same whether written forwards or backwards).
I am trying to edit data using checkbox value. Firstly, I created popup window which using querystring some data from main page. In popup window, I want to change the checkbox value. For example, I made setSpare column and given the value to show bit data type such as 0 or 1 using checkbox(false or true). If some data has non setSpare(means 0), it wil lbe come out uncheckbox. If I want to check it and clicking submit button, It was not change. I am going to show the code below.
public partial class AddSpare : BasePage { string ObjectId; protected void Page_Load(object sender, EventArgs e) { ObjectId = Request.QueryString["ObjectId"]; displayComInfo(ObjectId); } protected void displayComInfo(string ObjectId) // it informed relative data on web through using DB. { string query = "usp_ShowComputerList"; try { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SCSConnectionString2"].ConnectionString)) { SqlCommand cmd = new SqlCommand(query, conn); cmd.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter paramobjectId = cmd.Parameters.Add("@ObjectId", System.Data.SqlDbType.Int); paramobjectId.Value = ObjectId; conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { ModelTxt.Text = dr["Model"].ToString(); ModelTxt.ReadOnly = true; ComputerTxt.Text = dr["ComputerName"].ToString(); ComputerTxt.ReadOnly = true; userTxt.Text = dr["UserName"].ToString(); userTxt.ReadOnly = true; ntTxt.Text = dr["NtLogon"].ToString(); ntTxt.ReadOnly = true; HDDTxt.Text = dr["HddSize"].ToString() + "GB"; HDDTxt.ReadOnly = true; RAMTxt.Text = dr["MemorySize"].ToString() + "GB"; RAMTxt.ReadOnly = true; SerialNoTxt.Text = dr["SerialNo"].ToString(); SerialNoTxt.ReadOnly = true; TextBox1.Text = dr["Spare"].ToString(); inputChkSpare.Checked = (bool)dr["Spare"]; //(bool)dr["Spare"] display false or true. dr.Close(); } } } catch (Exception ex) { MessagePanel1.Type = MessageType.Error; MessagePanel1.Text = MessagePanel1.Text = "This is an error." + ex.Message; } } protected void okBtn_Click(object sender, EventArgs e) { string query = "usp_SetSpare"; try { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SCSConnectionString2"].ConnectionString)) { SqlCommand cmd = new SqlCommand(query, conn); cmd.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter paramobjectId = cmd.Parameters.Add("@objId", System.Data.SqlDbType.Int); SqlParameter paramspare = cmd.Parameters.Add("@spare", System.Data.SqlDbType.Char); paramobjectId.Value = ObjectId; if (inputChkSpare.Checked == true) // if I change the check box, it does not bring the changed value. It will bring the above value(already displayed thing) { paramspare.Value = "1"; } else { paramspare.Value = "0"; } conn.Open(); cmd.ExecuteNonQuery(); cancelBtn.Value = "Close"; okBtn.Enabled = false; MessagePanel1.Type = MessageType.Information; MessagePanel1.Text = "This computer is spare from now."; } } catch (Exception ex) { MessagePanel1.Type = MessageType.Error; MessagePanel1.Text = MessagePanel1.Text = "This is an error." + ex.Message; } }
I have a form with a bunch of checkboxes and textboxes. There will NOT be a "save" button on the page. What is the best way to save the work when data is entered in the textbox? I can do the checkboxes on a click changed event but how do I save data with the textboxes??
have two drop down list in my page. When i select one drop down, the value of second drop will change according to the value of first drop down. I don't want page refresh when i select my first drop down. So i use update panel but now when i select the value from my first drop down on the event of selectedindexchanged it will always shows me the default value and if i remove update panel it works perfectly but with page refresh. I don't know what is the problem. Values for both drop down is coming from database. Also i have done !IsPostBack in my page load but i don't know where is the problem..Please check the code below:
I have drop down list box that I would like to show two columns, is this possible? Or can it be done with a list box?The query correctly retrieves all of the table data to be displayed, one colum is an abbreviation, the other a bit longer description.
i have validation controls in my form. i have save and exit button in the form and side menus in the page...
i set property" causevalidation=false" to all the side menu controls and exit button....
so when i press side menu or exit button no validation fires...but the problem comes here... if the user accidently pressed save button(which already caused validation), and now he want to exit from the form and user dun wanna enter any details in the form.in that case i cudnt leave from the form coz of validation
I have a requirement in my application that, while saving the application, need to get all the value from drop down list and pass it to the view model. But application should not allow the user to select more than one item from drop down list manually, ie, only one value at a time. My view model is like ...
public class ListManagement { public IEnumerable<selectListItem> InactiveProduct { get; set; } public string[] InactiveProductSelected { get; set; } public IEnumerable<selectListItem> ActiveProduct { get; set; } }
In a page hving some textboxes and dropdownlists with every control having server side validation controls.On selecting a dropdown all the validation controls are disappear and on clicking the save button the page remains idle.