I have an ASP.NET gridview within which i have a template column which hosts a dropdown. the dropdown is bound from server side code. I am attaching the following JavaScript:
dl.Attributes.Add("onchange", "return UpdateTaskDetail(" + dl.ClientID + ",'" + u.TaskID + "','" + "');");
I am able to execute the JavaScript function name UpdateTaskDetail.
The issue in want to get the selected value of the dropdown for which i have been trying the following
var taskstatusid = $("#" + ctr.name + " option:selected").val();
This line does not fetch the value.
Can someone please tell me what might be incorrect?
In your UpdateTaskDetail function you can do something like this:
function UpdateTaskDetail(control, task, other ){
var taskstatusidVal = $("#" + control).val();//For selected value. remove "option:selected"
var taskstatusidText = $("#" + control + " option:selected").text();//For selected Text
alert(taskstatusidVal + taskstatusidText);//Test
}
Related
I'm trying to select the item in the Combobox based on the stored value in a Sorteddictionary
String value matching
comboBoxEdit3.SelectedItem = comboBoxEdit3.FindStringExact(Queries[_ucSetting.StandardSearchID.ToString()] + "(" + _ucSetting.StandardSearchID.ToString() + ")");
Elements in ComboBox
But this produces empty selection in the ComboBox
FindStringExact only returns the index of the first item that matches your string, or -1 if no match is found. You're trying to set the SelectedItem to the index being returned. You should set the SelectedIndex instead:
comboBoxEdit3.SelectedIndex = comboBoxEdit3.FindStringExact(Queries[_ucSetting.StandardSearchID.ToString()] + "(" + _ucSetting.StandardSearchID.ToString() + ")");
I am trying to draw a chart from SQL-Data, which currently looks like this:
This is the table db.GetTable(cmdGraph) returns:
How do I manage to change the labeling of the pie-parts to display the value of the field Count so that it looks like this?
This is the code that I use to draw the chart:
private void UpdateEvaluation(SqlCommand cmdGraph)
{
chPie.DataSource = db.GetTable(cmdGraph);
chPie.Series["Series1"].XValueMember = "Value";
chPie.Series["Series1"].YValueMembers = "Count";
chPie.DataBind();
}
And this is how it gets called:
UpdateEvaluation(new SqlCommand("SELECT Value, Count(*) as Count " +
"FROM DV.dbo.tbDefender " +
"WHERE Class LIKE 'Operating System' " +
"AND Type LIKE 'Caption' " +
"GROUP BY Value " +
"ORDER BY Count DESC "));
I found it out myself:
chPie.Series["Series1"].IsValueShownAsLabel = true;
The value IsValueShownAsLabel has to be set. Either programatically or through the Designer (In Properties under Chart Series and then look for IsValueShownAsLabel under Label)
Hey im currently having problems with WPF Datagrid using linq, currently im displaying a group of records from three tables into a datagrid, this works fine and i retrieve all the relevant information correctly.
However when i load the datagrid and i click on for example the 3rd record it selects the first record and i cant change it. I can use Ctrl + click to deselect the first record.
I dont know why its doing this but ive narrowed it down to my linq query, ive tried to write a more complex linq query using joins etc, it retrieves the same data but i still have this problem :/ any ideas would be good...thank you in advance
apptGrid.ItemsSource = (from o in DbList.OrderedAppointmentList()
from s in DbList.StaffList()
from c in DbList.ClientList()
where o.Appointment_Date == apptDatePicker.SelectedDate.Value
&& o.Staff_Staff_ID == s.Staff_ID && o.Client_Client_ID == c.Client_ID
select new
{
o.Appointment_Date,
o.Appointment_Time,
o.Duration,
StaffName =
((s.Middle_Name_s_ != null) ? s.First_Name + " " + s.Middle_Name_s_ + " " + s.Last_Name : s.First_Name + " " + s.Last_Name),
ClientName =
((c.Middle_Name_s_ != null) ? c.First_Name + " " + c.Middle_Name_s_ + " " + c.Last_Name : c.First_Name + " " + c.Last_Name)
});
Try a ToList() at the end of the query.
I had something similar like you, but to me happen, that when i add rows with the same data information, the selection seems to be crazy. what i did was not give a linq query as a itemsource else put all the information into a List and next pass it to the item source.
"ive tried to write a more complex linq query using joins etc,"
That's never going to help.
Write a program that is human readable (and not just computer readable). And I can bet, you will find the problem and the solution in that iteration.
On my page, whenever a DetailsView is updated, I must audit the changes into a database. On most pages this works perfect, as there were just textboxes - however on a page I am working on right now, with dropdownlists, my code isn't working.
Basically, what the code does is captures the Updating event of the SqlDataSource, creates a datareader to look at the contents of the row before it's updated, compares the contents to the parameters in the Update query of the SqlDataSource, and if one has changed to log this in a field in the Audit table. An extract of my code is below:
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
{
try {
if (reader[i].ToString() != e.Command.Parameters[i].Value.ToString())
{
fields[i] = reader.GetName(i) + ": " + reader[i].ToString() + " => " + e.Command.Parameters[i].Value.ToString();
}
}
catch {
if (reader[i].ToString() != "")
{
fields[i] = reader.GetName(i) + ": " + reader[i].ToString() + " => ";
}
}
}
}
When the control is on a dropdownlist, it seems to never go 'into' the IF even though the fields are different. Do I need to do something special to compare the values of dropdownlists? Note I believe the value is stored as an int in my table.
Thanks
Totally my fault. There was an extra parameter on the command which I had to exclude somehow.
I have created a multicolumn custom field and deployed it in SharePoint. To be able to use the field values from my custom field I also deployed an event receiver to copy the three values from my custom field to three separate regular text fields. If the three text fields do not exist I create them with XML in code. I also make sure the fields have the right visibility settings even if the field exist.
Creating the field in xml:
string fieldXml = string.Format("<Field ID=\"{0}\" " +
"Type=\"{1}\" " +
"Name=\"{2}\" " +
"StaticName=\"{2}\" " +
"DisplayName=\"{2}\" " +
"Required=\"{3}\" " +
"ShowInEditForm=\"TRUE\" " +
"ShowInNewForm=\"TRUE\" " +
"ShowInDisplayForm=\"TRUE\" " +
"ShowInListSettings=\"TRUE\" " +
"ShowInViewForms=\"TRUE\" " +
"ShowInVersionHistory=\"TRUE\" " +
"ShowInFileDlg=\"TRUE\"" +
"></Field>",
Guid.NewGuid(),
fieldType,
fieldName,
required);
list.Fields.AddFieldAsXml(fieldXml, true, SPAddFieldOptions.Default);
Make sure visibility settings OK when the field already exist:
field.ShowInEditForm = true;
field.ShowInNewForm = true;
field.ShowInDisplayForm = true;
field.ShowInListSettings = true;
field.ShowInViewForms = true;
field.ShowInVersionHistory = true;
field.Update();
list.Update();
I found no way of setting the ShowInFileDlg property programmatically once the field was created.
The thing is that this code works great up until I open a document in MS Word and the three text fields all have text assigned in the list but in Word they are empty!
Have anybody seen this before, what am I doing wrong!?
To be able to open a field in DIP (document information panel at the top in word documents) you need to add the SourceId property to the field:
SourceID="http://schemas.microsoft.com/sharepoint/v3"
For more information see here (msdn).