C# - Entering Values Into Dropdown And Saving?
Mar 17, 2010Is it possible for entering values into dropdown and saving that values to DB?
View 2 RepliesIs it possible for entering values into dropdown and saving that values to DB?
View 2 RepliesI Have the gridview control with 2 dropdown list and 2 text boxes,When the textbox chnaged event happen 1 row will create and the dropdown back to initial values( its not retaining the selected values),I am binding the control after text changed method,Is there any properties needs to be set or any other way we can retain the values in postbacks?
View 4 RepliesI am using the following code to bind BusinessID as the DataValueField of the ddlIndustry dropdown. What I want to do is save the selected ID to a different table (Company). I am doing this with ddlIndustry.SelectedValue. For some reason, the first value is always saved (1), and not the selected value.
[code]....
In the following code i want to save the value selected by user from drop downlist into database. but whatever value is selected by user, first value of dropdown lsit is saved to database
View
<% =Html.DropDownList("lstUsertype", (SelectList)ViewData["UserTypeID"])%>
Controller
public ActionResult CreateUser()
{
UmUser _UmUser = new UmUser();
UMRepository _UMRepository = new UMRepository();
EvoLetDataContext db = new EvoLetDataContext();
ViewData["UserTypeID"] = new SelectList(_UMRepository.FillUserTypes(), "UserTypeID", "UserType",2);
return View(_UmUser);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult CreateUser(UmUser _umUser)
{
//try
//{
if (ModelState.IsValid)
{
//try
//{
UserRepository _UserRepository = new UserRepository();
_UserRepository.Add(_umUser);
_UserRepository.Save();
return RedirectToAction("Details", new { id = _umUser.UserID });
/*}
catch
{
ModelState.AddModelErrors(_umUser.GetRuleViolations());
}*/
}
return View();
//}
/*catch
{
return View();
}*/
}
in a web form, i am having two drop down controls, and in the first one control i am having, state names like some thing, and in another i have to fetch the concurrent city names for the first control, like if i select city name as 'A' it must fetch the related city names for the 'A' how could i do this.
View 2 RepliesI am developing page for maintaing employee record using Visual Studio 2008, MS SQL server 2005. I am able to fetch and display all the employee information in gridview, the gridview have the dropdown list to display the employee type [ Part Time, Full Time, Permanent , Contract ], in the item template i am having dropdown list. IN the dropdown list i am displaying this. But While saving the record in gridview the droppdown selected index are changed to 0 of other dropdown list.
the user may be change the dropdown value from permanent to contract, or so. but while click on the save button in gridview, all the previous selection are gone, and always showing the first record of dropdown list. I know this is happening because we are doing dropdown list bind on onRowDataBound.
i am trying to save the values from 3 radiobuttons in my database and i cant get it to work . Please see my code below:
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim smoker As String = "No"
Dim pastsmoker As String = "No"
[code...]
I am having requirement to save Event Details in one table and Event Pass Type Vlaues in another table,I have done similar task forĀ SMS before, where I saved SMS Message in one table and sms sent to n no. of Mobile Numbers.But in this scenario the values which I need to save in another table are three(like Passtype,Quantity and Price), I need to save EventĀ Details in tbl_EventDetails Table and EventPassType details in tbl_PassTypeCategory with specific EventID(foregn key in this table and Primary Key in tbl_EventDetails).
Below are the 2 Sps for SMS(which I created before) and EventDetails which is giving wrong output....
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
[Code].....
I am reviewing some web code and I am not exactly sure how ASP.net session state works. If a User object is saved to the session state during login, and User.FirstName and User.LastName is set. If other web pages retrieve the user object from the session and set the FirstName to something else is that persisted on other web pages? Or, do you need to re-add the user object back to the session once it has been modified?
View 3 RepliesI am having 2 list box in my form. I am adding some values from 1st list box to 2nd one. What i need is i would like to save the data in the list box in sql table.
View 6 RepliesI'm having a bit of a problem with this code.
The program gives me a list of checkboxes but a user ID. then u user can change his selection and push the save button (id="btnSaveUserIntersts") and i am trying to save in the hidden textbox all the values of the checkboxes that was choosen.
The problem is that i am getting all the time the same selections that came form the database and not getting the new selection that the user made.
what am i doing wrong here?
[code]...
Is it possible to first add controls (ie. CheckBoxes) to a GridView with AutoGenerateColumns set to true. Then to click a single save button which loops thru the controls in the GridView, gets their values (ie. Checked/Not Checked) and then saves those values to a database?
View 9 RepliesHow can I keep the values in dropdown after a postback? I have this code:
[Code]....
The dropdonws is set to autopostback. How can i bind the dropdowns in a better way then I do now? When I post back the dropdowns are set to default value.
I have 2 dropdowns on my form, ddlMake & ddlModel. I want that ddlModel should have the corresponding value for which I have clicked the ddlMake dropdown, something like the cascading dropdown.
Here's my code :
[code]......
Now i need adding cusome values in dropdown. meantime. I had dropdown named like biodata, its consists of age, gender,sex, religion. Now i need add item name custom in Dropdown for users chooses its from dropdown another pop-up will appear, and it had some items in form and they filled it up thier details respectively. and click ok then The selected values are returned to grid.
View 2 Repliesthe code for getting the dropdown selected values (both TextField and ValueField) in MVC Controller class.
This is my case, I have a dropdown filled with Product category. Its having default value as "--Select--". I want validate this dropdown selected any values or not in controller action method. How will i do this stuff?
The DDL values are fully visible in Firefox but not in IE.
<img border="0" src="http://i212.photobucket.com/albums/cc241/coolcupidjny/DDIEbug.jpg" alt="IE" width="304" height="228" />
<img border="0" src="http://i212.photobucket.com/albums/cc241/coolcupidjny/DDFFbug.jpg" alt="IE" width="304" height="228" />
I've spent a lot of time trying to figure out how to do a drop down for filters. Right now I have two filters as a textbox but I want a dropdown list instead as I would be adding few more filters. This is my index page:
Task List
<ul>
<% using (Html.BeginForm("Index", "Task"))
{%>
<fieldset>
<legend>Filters</legend> [code].....
This is the change I made in my Model:
public class FilterViewModel
{
public PapClientProfile Client { get; set; }
public PapStaff Physician { get; set; }
[code]...
But I'm not able to populate any dropdown values.
I have 3 drop down list boxes - One for month, day and year. I'm trying to get the value of what the user selects on those drop down list boxes. I have dynamically populated my drop down list boxes and I'm trying to output the end value on a label
private int month;
private int day;
private int year;
protected void Page_Load(object sender, EventArgs e)
{
for (month = 0; month <= 12; month++)
{
DropDownList2.Items.Add(month.ToString());
}
for (day = 0; day <= 31; day++)
{
DropDownList3.Items.Add(day.ToString());
}
for (year = DateTime.Now.Year; year <= DateTime.Now.Year + 75; year++)
{
DropDownList4.Items.Add(year.ToString());
}
}
protected void Button4_Click(object sender, EventArgs e)
{
month = ?
day = ?
year = ?
Label7.Text = month + "/" + day + "/" + year;
The problem right now is I can't figure out how to actually retrieve the value the user uses
I want to add the below values from Enum to drop down list
<option value="0">-- Select --</option>
<option value="AC">Active</option>
<option value="IN">InActive</option>
<option value="PC">Pending Closure</option>
I have started learning ASP.NET. I am Trying to filter GRIDVIEW values on basis of dropdown selection.I am working trying to do this with AJAX.
When a user selects any value from the drop down..suppose an employe ID.the gridview is filled with data according to that empID.
how Can I do that.
sorry for the naive question, but it looks it should work and it does not. Say I have this simple scenario: a controller with its view with a single action, Index. The view has a form with a dropdown with some letters and submit button. When the form is submitted (to the same Index action of the same controller) the controller should fetch from a repository all the persons whose last name begins with the selected letter and pass it back to the view. So my controller is like this (I'm using the MVC Contrib data grid):
[Code]....
The view form (a strongly typed view whose model is an IEnumerable of Person EF objects) looks like this:
[Code]....
This works the 1st time I submit the form, but whenever I click the next/previous button of the pager the Index action is invoked but I cannot read the dropdown selection: I tried with Request.Form and with a different signature in the action (by adding it a string LastName parameter), but I always get NULL instead of the selected value, so that the query returns no persons. What I'm doing wrong? How can I read the dropdown value across posts to the same action?
I have a ASP:DropDown list which is populated by the following:
public void Fill1()
{
string connectionString = WebConfigurationManager.ConnectionStrings["CRM2Sage"].ConnectionString;
using (SqlConnection _con = new SqlConnection(connectionString))
using (SqlCommand cmd = new SqlCommand("SELECT * FROM Products", _con))
{
[Code]....
I would like someone to explain how I can pass a drop down list from the presentation layer to the controller using the Model View Controller Design Pattern from Microsoft in order to bind enum values to it?
View 2 RepliesI have an improvised system to enter data, below the gridview. I need to populate one dropdown only with the values which relate to the value selected in the drop down before that. For example. I have a dropdown for Customers and another for ShipTo. I want Shipto dropdown to populate only with the values which relate to the particular Customer selected.
[Code]....