You query is still failing, you are seeing "Updated data successfully"
because it is outside of the if statement.
Try this:
if(!$retval){ //query has failed, produce error
die('Could not update data: ' . mysql_error());
}
else{ //query is successful
echo "Updated data successfully
";
mysql_close();
}
You need a loop:
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Country", typeof(string)));
foreach(ListItem item in DDLCountry.Items)
{
DataRow dr = dt.NewRow();
dr.SetField("Country",item .Text);
dt.Rows.Add(dr);
}
Grd1.DataSource = dt;
Grd1.DataBind();
or the minimized version:
DataTable dt = new DataTable();
dt.Columns.Add("Country"); // string is default
foreach (string country in DDLCountry.Items.Cast<ListItem>().Select(i
=> i.Text))
dt.Rows.Add(country);
You should implement the RowCommand event from the GridView. You alredy
have the CommandField, so do something like this:
void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
{
//
// Get the keys from the selected row
//
LinkButton lnkBtn = (LinkButton)e.CommandSource; //the button
GridViewRow myRow = (GridViewRow)lnkBtn.Parent.Parent; //the row
GridView myGrid = (GridView)sender; // the gridview
int reviewid = Convert.ToInt32(GridView1.DataKeys[myRow.RowIndex].Value);
//value of the datakey **strong text**
// If multiple buttons are used in a GridView control, use the
// CommandName property to determine which button was clicked.
// In this case you are pressing the button Select, as ou already
// defined this at the aspx code.
if(e.CommandNam
I just moved the two onchange functions (other than firstone) to other
views, which load my dropdowns. Actually it was a post back issue, so on
single view Change for more than one "ddl" was not fired. Moving it to
Partial Views did the trick
Your changeCountry method should be changing the value of the underlying
observable that you have bound the select to:
function changeCountry(isoId)
{
selectedCountry(isoId);
}
That should then update both, as far as I'm aware.
You will also need to pass the new id in as a string, as knockout may well
be using the type equality comparer (===), and the value in the html will
be a string.
You seem to be binding the dropdown to a complex property on your model
(Country) which obviously is not supported. Dropdowns should be bound only
to simple scalar type properties. So you should define a property that will
hold the selected value on your EventObject view model:
public string SelectedCountry { get; set; }
Then in your controller action you should set this property to the value of
the country you want to be preselected:
using (Country objContry = new Country())
{
ViewData["Countries"] = new SelectList(objContry.GetAllCountry(),
"Country", "Country");
}
lst[0].SelectedCountry = "Argentina";
return View(lst[0]);
and in your view:
@Html.DropDownListFor(
model => model.SelectedCountry,
(SelectList)ViewData["Country"],
new { id = "ddlCountry" }
)
I
Add the SelectList to your model:
public SelectList DropDownList { get; set; }
build the class for that collection:
public class MyListTable
{
public string Key { get; set; }
public string Display { get; set; }
}
and then in your controller, load the data for the MyListTable class from
the database:
var list = new List<MyListTable>();
using (SqlConnection c = new SqlConnection(cString))
using (SqlCommand cmd = new SqlCommand("SELECT KeyField, DisplayField FROM
Table", c))
{
using (SqlDataReader rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
list.Add(new MyListTable
{
Key = rdr.GetString(0),
Display = rdr.GetString(1)
});
}
}
}
var model = new users();
model.Drop
try this one
put this one
var base_url="<?=base_url()?>"
somewhere inside the script tag may be before
$(document).ready(function(){
line
and change the line
url: "upload1_site/upload",
with
url: base_url+"upload1_site/upload",
please let me know if it works or not.
You can just store the selected item text in onw variable, like the below:
dim selText as string = DropDownList1.SelectedItem.Text
and on the click of submit button, perform your required tasks and then
redirect page to another page along with the department name. Like the
below code:
Response.Redirect("Page2.aspx?department=" + selText)
and on the second page i.e. Page2.aspx, just receive this value in query
string, using below code.. wherever it is necessary either on page load or
at your required place.
If Request.QueryString("department") <> Nothing Then
dim departmt as string = Request.QueryString("department")
End If
And use the above variable's value in your database query and get the
related data to the department selected in the previous form.
I hope it will h
You did not provide any code of what you have done so far so I know nothing
about the data that you have been working with. I will post some code and
all that you will have to do is to modify it to fit in with your scenario.
Lets work with a simple solution of loan applications. A client needs to
apply for a loan and he needs to supply banking details. He will have to
select a bank from a drop down list.
Lets start with the domain model called Bank. This represents your data
coming from your database table. Lets call the table Banks.
public class Bank
{
public int Id { get; set; }
public string Name { get; set; }
}
Your table called Banks will look like this:
Id | int | not null | primary key
Name | varchar(50) | not null
Depeneding on you what you need to do I normally
You can delete all and then repopulate or you can store the initial state
of the list of friends, then compare with the final list after user edit.
I recommend you use this function array_diff($array1, $array2), doing
something like:
$initial_list = array (1,2,3,4,5);
$list_after_edit = array (1,2,5,6);
$all_new_items = array_diff($list_after_edit,$initial_list);
foreach ($all_new_items as $item) {
// Add to database this item
}
$all_deleted_items = array_diff($initial_list,$list_after_edit);
// Execute this query:
$query = 'DELETE FROM table WHERE `User Id` = <some ID> AND `Friend
Id` in (' . implode(',',$all_deleted_items) . ')';
You need to implement AutoCompleteTextView. This allows suggestions as the
user is typing. You can bind the data to be searched for, using Adapters.
This should solve your problem.
An example that might be helpful can be found here.
Dont write the code in dropdowns selected index changed event write it in a
function and call it in pageload event
you have to set the DataTextField and DatavalueField
objc.ClientName = Convert.ToString(Session["ClientName"]);
DataSet ClientN = obj.GetClientList();
DataView Projview = new DataView();
Projview.Table = ClientN.Tables[0];
DrpClientName.DataSource = Projview;
DrpClientName.DataTextField="Description";
DrpClientName.DataValueField="ID";
DrpClientName.DataBind();
Sounds like a typical outside-digest-cycle problem. Right after you get the
countries make sure you call $scope.$apply(), or wrap the request (jQuery
or whatever) around $scope.$apply(function() {....});
That is because you are loading your subject along with the course, if you
want to load your subject AFTER choosing course, what you can do is put
your subject into a div(or tbody) tag like this
<div class="subject"></div>
and in your jquery:
$("#course_code_id").live("change keypress",function(){
var id = 0;
id = $(this).val();
if( $(this).val() !==''){
$.post('<?php echo site_url('subject/search_by_course') ?>',
{
subject_id: id
},function(data){
$(".subject").html( data['html_string']);
},"JSON"
);
}
});
in your controller
function search_by_course()
{
$this->load->model('subject_model');
$id = $this->input->post('subject_id');
/
In the question's comments, it was established that even though the UI was
being updated (based on user interaction), the underlying data used by
adapter's getView() weren't.
Solution: Update the data source and call notifyDataSetChanged() on the
adapter. Let getView() handle UI updates.
Read through the comments for more information.
Do it something like this
<?php echo $form->dropdownList($products,'product_name',
CHtml::listData(Products::model()->findAll(), 'id', 'product_name'),
array('id'=>'productType','name'=>'productType'))); ?>
Your hidden variable
<?php echo
CHtml::hiddenField('productTypeId','',array('class'=>'ProductTypeId'));
?>
And the javascript code to select the id
$('#listingType').change(function(){
var productid=$('#productType').val()
$(".ProductTypeId").val(productid);
});
In controller action
public function actionCreate(){
$productId=$_POST['productTypeId'];
//code to store in sales table
}
I posted directions on how to do this here some time ago:
http://www.eggsurplus.com/content/populate-a-dropdown-from-the-database/
What you need to do is to create a custom util function and then tell your
vardefs for that field to call the custom util function.
//custom/Extension/application/Ext/Utils/getAccounts.php
function getAccounts(){
static $accounts = null;
if(!$accounts){
global $db;
$query = "SELECT id, name FROM accounts";
$result = $db->query($query, false);
$accounts = array();
$accounts[''] = '';
while (($row = $db->fetchByAssoc($result)) != null) {
$accounts[$row['id']] = $row['name'];
}
}
return $accounts;
}
Name of the file doesn't matter. Make sure to include opening PHP tags.
you can refer to this question: jQuery - setting the selected value of a
select control via its text description
But if you use php to build the option html, why not set the selected
option with php.
Something like this in your loop (just an example!)
<?php
$sel = '';
if($rowsakh['diet_id'] == $_POST['someVarName'])
{
$sel = 'selected';
}
echo ' <option value="' . $rowsakh['diet_id'] . '|' . $bnum . '"' .
$sel . '>Audi</option>';
?>
I personnaly wouldn't use echo statements in the while loop. I would
concatenate it as a long string and finally echo once at the end.
The default DropDown helper that is provide in asp.net mvc does not
support multiselet.
You'll have to create your own custom multiselect dropdown helper.
Here are some links that can help you create you own custom dropdown
helper:
http://blogs.msdn.com/b/rickandy/archive/2012/01/30/asp-net-mvc-dropdownlist-multiselect-and-jquery.aspx
http://utsavized.com/chosen-multiselect-dropdown-list-with-asp-net-mvc3/
I can't exactly tell what the problem is without seeing your actual code
structure, but generally I think it's a good idea to populate you selects
before initializing the plugin, so the best approach would be to add the
plugin initialization on your elements in your ajax callback after the
options have been added.
var callbackSuccess = function(data){
if ( data ) {
populateDropDownById(data, 'objectiveBanks');
$(".chzn-select").chosen();
$(".chzn-select-deselect").chosen({allow_single_deselect:true});
//Other things
}
};
If you need to add options to your <select> elements after the plugin
is initialized, you'd need to trigger the chosen:updated event on the
field, ex:
$(.chzn-select").trigger("chosen:updated");
It looks like you are using the designer to setup your dropdown list data
source. Here is how you could do it in code:
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
MyLinqToSqlDataContext db = new MyLinqToSqlDataContext();
var result = from c in db.Customers
select g;
customerName.DataSource = result.ToList();
customerName.DataTextField = "Name";
customerName.DataValueField = "ID";
customerName.DataBind();
...
}
}
There is problem in your page load. Add ispostback checking in Pageload.
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
Add_Dep();
}
}
try this
http://jsfiddle.net/jW6eL/7/
$("#mode").on('change', function () {
var rows = parseInt(this.value);
console.log(rows);
var lastRow;
for (var i = 0; i < rows; i++) {
lastRow = $('#engagements tr').last().html();
$('#engagements
tr:last').after('<tr>'+lastRow+'</tr>');
$('#engagements tr:last').find('select').each(function(){
var this_select=$(this);
this_select.val(this_select.closest('tr').prev().find('td:eq('+this_select.closest('td').index()+')').find('select').val())
})
}
});
There are a lot of options, but you shouldn't start with the items
hard-coded in your markup.
Quick solution:
Have a private List<string> variables set up for each of the
collections of numbers (I say string instead of int because ListItems will
be converted to strings).
So for instance,
private List<string> personalLoanIds = new List<string> ()
{"12", "24"};
When ddlLoanType is changed to Personal Loan, you can set your
ddlDuration's DataSource to personalLoanIds then call the DataBind()
method.
You should not use the same value (IDCountry) as first and second argument
for the dropdown. The first argument represents the value to bind the
dropdown to while the second represents the available values. So:
@Html.DropDownList(
"SelectedCountryID",
(IEnumerable)ViewBag.IDCountry,
new { @class = "span6" }
)
To avoid all those confusions with Dropdowns I would recommend you using a
view model:
public class MyViewModel
{
public string SelectedCountryID { get; set; }
public IEnumerable<SelectListItem> Countries { get; set; }
}
and then your controller action will populate and pass this view model to
the view:
public class HomeController: Controller
{
public ActionResult Index()
{
var model = new MyViewModel();
// preselected an elem
You should filter the duplicate row before setting the source of the
gridview. This will allow you to sort before the binding the grid as well.
This will depend on the source of the dataset ds, how are you getting this
data?
Rowdatabound should not be used to remove/add rows to the table, that
should be done to the the table stores in the dataset ds
The issue here is that after the Update, links to other entities are NULL
for the updated row. What you can do is use the ID that corresponds to the
link to the other entity and do an on-demand look-up.
That is, maybe your is defined like <%# Eval("Customer.FirstName") %>,
after the update, that row might be empty because the attribute "Customer"
that is the link to the customer entity to get the first name, is null. So
just define the like so:
<%# Eval("Customer.FirstName") ??
Customer.GetFirstNameByID(Eval("CustomerID")) %>
You would define the function GetFirstNameByID inside the Customer entity
class to return the customer first name. Now after an update, if and when
the "Customer" attribute is null, the first Eval() will return null so the
second statement will exe
I had a similar problem related to populating drop down menus in a formset
based on a user selection (which could be multiple rows in a table). What
worked for me was to modify the base_fields in the formset before I put the
selected rows in the formset like so:
formset = modelformset_factory(mymodel)
formset.form.base_fields['my_parameter'] =
forms.ChoiceField(choices=getMyParamChoices())
finalformset =
formset(queryset=model.objects.filter(id__in=request.POST.getlist('selection')
'selection' is the list of selected rows from the previous page.
getMyParamChoices() is a function that queries a model to get the list of
pulldown choices like so:
def getMyParamChoices():
'''Go get the list of names for the drop down list.'''
all = anothermodel.objects.all()
params = []
for item in all:
You assign data to mdl.CancellationAmount in a wrong way. It is already
observable so you should use () to assign value in done function. Rewrite
your callback as follow:
.done(function (response) {
mdl.CancellationAmount(response);
})
this.collection.on("add", this.addDisplayView, this);
Then create a function addDisplayView that accepts the model for the view.
You will need to refactor the this.collection.each(function(item)... part
of your code to use the addDisplayView function.
GroupListView.prototype.addDisplayView = function(model){
var displayView = new app.GroupListDisplayView({
model: model,
collection: this.collection
});
// use this.$, as it is already mapped to the context of the view
return this.$("#people-groups-list").append(displayView.render());
}
You should also change this.collection.push(this.model); to
this.collection.add(this.model);
addcollection.add(models, [options])
Add a model (or an array of models) to the collection, firing an "add"
event. If a m
Things to check:
Did you save your core data entities with [managedObjectContext
save:&error] at the appropriate places (e.g. before displaying the new
table view data)? Did you check the error variable?
Did you migrate your model correctly with a new model version?
Are you reading the correct attributes and displaying them correctly (in UI
or log statements)?
BTW, in your code you are setting the request entity twice.
Which thread is calling this slot?
Remember that if the QObject emitting the signal and the QObject receiving
it live in the same thread then the connection will be direct and not
scheduled using an event queue.
It might be that your event thread is the one processing the loop that
contain the emit. In this case your application will never update the GUI
since it is locked processing your loop.
Are you doing the frames acquisition in a separate thread?
Here is a idea to start. Consider 2 dropdown like this.
<select id="Numeric">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<select id="Alphabets">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
Based on the value of 1st dropdown i am selecting the second dropdown
var val = document.getElementById("Numeric").value;
var obj = document.getElementById("Alphabets");
if(val == "1") obj.value = "A"
else if(val == "2") obj.value = "B"
else if(val == "3") obj.value = "C"
Switch is more better
switch(val)
{
case("1"):
obj.value = "A";
break;
case("2"):
obj
Check the GridView's DataSource before you do the DataBind(). Since you're
missing the full ASPX markup, I'm not sure if you're setting the data
source programmatically or with a SqlDataSource.
In any case, what will happen often with programmatically-set Data Sources
is that they disappear on a PostBack, and when you call that DataBind,
you're really DataBinding it to null, which would explain why you're
getting string.Empty ("") for the Label's Text property.