i am waiting help me as soon as possible i have text box and two radio box if one radio box i selected and click button that the value of that radio box should display in text box how can i do this i am try by this code but i could not get still
correct this
string gender;
if (radio_male.Checked)
{
gender = "Male";
}
if (radio_female.Checked)
{
gender = "Female";
}
textbox.Text = gender;
Firstly, saying "correct this", isn't the thing stack overflow is for, and it isn't really inviting us to answer your question either.
Also, next time, please give a bit more information (what have you tried? what is the error that is generated? what doesn't work properly), that way it is easier to answer,
But anyway, the answer.
I'm guessing that you're getting the error "use of uninitialized variable", since you do not necessarily initialize gender, which is required in C#.
Replacing string gender; with string gender = ""; should do the trick.
Related
This is going to sound very weird but it will make the code for this app very compact.
Is there a way to call a .operator conditionally. Here is an example
say I have a class with three values that I can do a . on.
class A {
int intOne;
int intTwo;
int intThree;
}
to get the intOne in class A you can do A.intOne right....
but what if you you wanted the string at the right of the . to conditionally be there.
A."conditionalvariable"
so if a user clicks a button say button A then the conditional variable will be A.intOne.
and if the user clicks button b then the value of "conditionalvariable" will be intTwo and therefore you will be getting the data.
please assume that I am not stupid, and I am needing this exact thing for a specific use case. If you post an answer that is not this exact solution it will not be accepted.
example:
var a;
switch (name) {
case "intOne":
a = A.intOne;
break;
...
}
//this is not an acceptable answer
I realize that this would be an "answer" to this question, but it actually isn't I need the exact thing stated because I am using streams.
here is that use case I was talking about. I could explain away all day as to why I need it this way, but either way this either does exist or doesn't so a simple no this doesn't exist is an acceptable answer.
return StreamProvider.value(
value: classDataNotif.homework,
)
based on what is clicked before this widget the "homework" will need to change to "notes", or "tests".
You cannot do a switch above this because it will be calling the stream to early and cause the widget to crash. doing a switch inside the widget and copying code over would defeat the purpose. in order to make the code as compact and as easy to write as possible i need the string at the right of the . operator to change.
thanks in advance :)
I want to display Icon based on it's name parsed from external source. Now i have several newsfeeds integrated in app, like this:
myPages.add(new Subpage(0, "Main", FontAwesome5Regular.newspaper, "http://url.one"));
myPages.add(new Subpage(1, "Buses", MaterialCommunityIcons.bus_multiple, "http://url.one"));
where 3-d argument of SubPage constructor is IconData.
I want to generate so much pages as needed, based on CSV. I want to place in CSV lines like
0, Main, FontAwesome5Regular.newspaper, "http://url.one"
1, Buses, MaterialCommunityIcons.bus_multiple, "http://url.two"
I have no problems with parsing csv, but I don't understand how to convert parsed String "FontAwesome5Regular.newspaper" to IconData needed by constructor of Subpage.
It would be great to get solution without async/await, catching error, etc, cause I'm really sure, that CSV contains no errors, all strings are valid, all classes are available
Thank you for any ideas!
You could use 'dart:mirrors' library for that, but, unfortunately, library isn't available in flutter, so you can't access classes' static properties using their names as string. You can do it like this:
IconData getIconData(String str) {
switch (str) {
case "FontAwesome5Regular.newspaper": return FontAwesome5Regular.newspaper;
case "MaterialCommunityIcons.bus_multiple": return MaterialCommunityIcons.bus_multiple;
default: return null;
}
}
great workaroud from Richard Heap:
Can you change your CSV? Let's say you want to send an umbrella icon. Rather than "MaterialIcons.beach_access" send "MaterialIcons" in one column and "60222" in another. Parse the 60222 into a int: var codePoint = int.parse(cp); and make your icon as var icon = IconData(codePoint, fontFamily: ff);
– Richard Heap 2 hours ago
I have two Visualforce pages, and for several reasons I've decided it is best to pass a datetime value between them as a string. However, after my implementation my date always appear to be null even though my code seems to compile.
I have researched quite a few formatting topics but unfortunately each variation of the format() on date time seems to not produce different results.
The controller on page 1 declares two public variables
public datetime qcdate;
public String fdt;
qcdate is generated from a SOQL query.
wo = [SELECT id, WorkOrderNumber, Quality_Control_Timestamp__c FROM WorkOrder WHERE id=:woid];
qcdate = wo.Quality_Control_Timestamp__c;
fdt is then generated from a method
fdt = getMyFormattedDate(qcdate);
which looks like this
public String getMyFormattedDate(datetime dt){
return dt.format(); }
fdt is then passed in the URL to my next VF page.
String url = '/apex/workordermaintenanceinvoice?tenlan='+tenlan +'&woid=' + woid + '&invnum=' + invnum + '&addr1=' + addr1 + 'fdt=' + fdt;
PageReference pr = new PageReference(url);
I expected when calling {!fdt} on my next page to get a proper string. But I do not.
UPDATE:
Sorry I guess I should not have assumed that it was taken for granted that the passed variable was called correctly. Once the variable is passed the following happens:
The new page controller creates the variable:
public String fdt
The variable is captured with a getparameters().
fdt = apexpages.currentPage().getparameters().get('fdt');
The getfdt() method is created
public String getfdt(){
return fdt;
}
Which is then called on the VF page
{!fdt}
This all of course still yields a 'blank' date which is the mystery I'm still trying to solve.
You passed it via URL, cool. But... so what? Page params don't get magically parsed into class variables on the target page. Like if you have a record-specific page and you know in the url there's /apex/SomePage?id=001.... - that doesn't automatically mean your VF page will have anything in {!id} or that your apex controller (if there's any) will have id class variable. The only "magic" thing you get in apex is the standard controller and hopefully it'll have something in sc.getId() but that's it.
In fact it'd be very stupid and dangerous. Imagine code like Integer integer = 5, that'd be fun to debug, in next line you type "integer" and what would that be, the type or variable? Having a variable named "id" would be bad idea too.
If you want to access the fdt URL param in target page in pure Visualforce, something like {!$CurrentPage.parameters.fdt} should work OK. If you need it in Apex - you'll have to parse it out of the URL. Similar thing, ApexPages.currentPage() and then call getParameters() on it.
(Similarly it's cleaner to set parameters that way too, not hand-crafting the URL and "&" signs manually. If you do it manual you theoretically should escape special characters... Let apex do it for you.
I am trying to make a calculator app in swift as a practise for my IOS development course. for that app I am trying to append a number to an existing double or integer after the user pressed on a specific button, but I don't know how.
if the user pressed on lets say a 5, then I want that the code should append that 5 to the numbers he pressed before
for instance:
the user has typed the following number:
6797.890
and now he wants to add the 5 to the existing number so that the number would be:
6797.8905
I really don't know how to do this in the code, and I really appreciate it if someone could help me by showing how or giving some resource website's for this problem
thanks a lot!
Benji
I know you mentioned that you are supposed to use an Int or Double, but I would try and use NSDecimalNumber and String if you can. It will give you the precision you want and has a convenient way to turn the string into an NSDecimalNumber, NSDecimalNumber(string: "6797.8905"), as well as back to a string, number.stringValue. You can enteredAmount != NSDecimalNumber.notANumber just in case your user input is incompatible.
You must process the input as a string. If you process it as a double, the trailing zero will be lost and your code will not be able to distinguish between adding "5" to 6797.890 and adding "5" to 6797.89
Only convert from String to Double in one direction (from input to data) after displaying the initial value.
I'm using a plugin and want to perform an action based on the records statuscode value. I've seen online that you can use entity.FormattedValues["statuscode"] to get values from option sets but when try it I get an error saying "The given key was not present in the dictionary".
I know this can happen when the plugin cant find the change for the field you're looking for, but i've already checked that this does exist using entity.Contains("statuscode") and it passes by that fine but still hits this error.
Can anyone help me figure out why its failing?
Thanks
I've not seen the entity.FormattedValues before.
I usually use the entity.Attributes, e.g. entity.Attributes["statuscode"].
MSDN
Edit
Crm wraps many of the values in objects which hold additional information, in this case statuscode uses the OptionSetValue, so to get the value you need to:
((OptionSetValue)entity.Attributes["statuscode"]).Value
This will return a number, as this is the underlying value in Crm.
If you open up the customisation options in Crm, you will usually (some system fields are locked down) be able to see the label and value for each option.
If you need the label, you could either do some hardcoding based on the information in Crm.
Or you could retrieve it from the metadata services as described here.
To avoid your error, you need to check the collection you wish to use (rather than the Attributes collection):
if (entity.FormattedValues.Contains("statuscode")){
var myStatusCode = entity.FormattedValues["statuscode"];
}
However although the SDK fails to confirm this, I suspect that FormattedValues are only ever present for numeric or currency attributes. (Part-speculation on my part though).
entity.FormattedValues work only for string display value.
For example you have an optionset with display names as 1, 2, 3,
The above statement do not recognize these values because those are integers. If You have seen the exact defintion of formatted values in the below link
http://msdn.microsoft.com/en-in/library/microsoft.xrm.sdk.formattedvaluecollection.aspx
you will find this statement is valid for only string display values. If you try to use this statement with Integer values it will throw key not found in dictionary exception.
So try to avoid this statement for retrieving integer display name optionset in your code.
Try this
string Title = (bool)entity.Attributes.Contains("title") ? entity.FormattedValues["title"].ToString() : "";
When you are talking about Option set, you have value and label. What this will give you is the label. '?' will make sure that the null value is never passed.