I am having an issue with this blank space " " showing up in my textbox if the table row is null. so i would like to replace this " " with this "". For example here is what i have:
StartTime.Text = row.Cells[5].Text;
so here is pseudo-code of what i am trying to achieve:
if (StartTime.Text == "" " then replace it with " ")
else show the value of StartTime.Text
I know my C# skills is so bad so please help. thanks
what about StartTime.Text = row.Cells[5].Text.Replace(" ", " ")
or i haven't understood the question correctly
Related
Can somebody tell me what is wrong? This is my RDLC expression:
=IIF(Last(Fields!totalHour.Value) <> "" OR "--:--" , "Total Hours " & Last(Fields!totalHour.Value), " ")
And it is returning #ERROR
I don't know if it is happening because it returns a null value, but if it is what should i do?
And if i set to always show the value it works:
=Last(Fields!totalHour.Value)
I also tried this and it keeps sending the same error:
=IIF(Last(Fields!totalHour.Value) <> "" OR "--:--" OR "00:00" , "Total Hours " & Last(Fields!totalHour.Value), " ")
This is the information that is passing to my dataset : "00:00"
This will fix the issue you are comparing string, not int. Your expression will work if it is an int but fail if the value is a string so you need to write it separately like below.
=IIF(Last(Fields!totalHour.Value) <> "" OR Last(Fields!totalHour.Value) <> "--:--" , "Total Hours " & Last(Fields!totalHour.Value), " ")
I know it will not work for everybody, but for the solution i just made one camparision and it worked!
=IIF(Last(Fields!totalHour.Value) = "00:00" , "Total Hours " & Last(Fields!totalHour.Value), " ")
I'm creating a standard calculator with a history feature. Previous solutions will show in a label box every time the user clicks the "=" button
After converting this string:
string histo = (operand1 + " " + operation + " " + " " + operand2 + " = " + result);
To a list by using this code:
List<string> hist = histo.Split().ToList()
What I want to do next is to print it to a label box to show history. How can I do that? Thank you.
Your question is not very clear and I do not think that label is a good choice to show the history. Combobox would be a better option, if you want to allow users to select items from history.
As far as your question on how to display it in a label is concerned you can use the following code. You can replace "," with Environment.NewLine.
lbl.Text = String.Join(",", hist);
I know I must be being stupid here, but I can't work out why this code isn't working. I'm very new to Razor, so please go easy on me.
I have the following code in my markup: (I've cut it down to be as simple as I can make it while still reproducing the issue so that I can hopefully diagnose the issue easier)
string testVar = "test";
#testVar
It returns the following:
error CS0103: The name 'testVar' does not exist in the current context
I've tried using different names for the variable, I've tried having it use "var" instead of "string" for it's declaration, I've tried assigning various different values to it, I've tried surrounding the variable in brackets like #(testVar), but the issue is still there. It's very frustrating, because in another part of my code I have
string prop = #p.Name + " (" + #p.PropertyType + ") - " + #p.GetValue(#page, null).ToString() + "\r\n";
#prop
which works fine.
I can't think what could be causing it, and it's starting to frustrate me.
Thanks,
YM
In Razor when we want to write c# statements we have to tell it that from here c# code starts:
#{ // from here c# block starts
string testVar = "test";
} // here ends
Now if you want to access this variable in html you can do like this:
<span>#testVar</span>
When you are writing:
string prop = #p.Name + " (" + #p.PropertyType + ") - " + #p.GetValue(#page, null).ToString() + "\r\n";
it is considered as plain text and will be rendered on browser like "string prop = ..."
you have to tell that it is c# code by following way:
#{
string prop = #p.Name + " (" + #p.PropertyType + ") - " + #p.GetValue(#page, null).ToString() + "\r\n";
}
I want to display message within the label by code behind.My code do look like as below.
lblmsg.Text = "Success: You have added " + pujaname + " to your shopping cart ";
Here "pujanme" is extracting from database which is coming correctly and secondly I want to inlcude "shopping cart" text which is hyperlink to other page but I am geting error.I will be pleased if somebody guides me.
Thankyou
You can try this. It is working for me.
lblmsg.Text = "Success: You have added " + pujaname +" to your shopping cart ";
You have to escape the double quotes in your link (by adding a backslash in front of them):
lblmsg.Text = "Success: You have added " + pujaname +
+ " to your shopping cart ";
You just have to precede the inner " of url with \.
lblmsg.Text = "Success: You have added " + pujaname + " to your shopping cart ";
If its vb then you can just write it simple like below: Html can be put inline as long as they are in between double quotes:
lblmsg.Text = "Success: You have added " + pujaname + " your shopping cart "
I need a statement to select data from an MS Access database table.
WITHIN selected dates
I have two textboxes in my GUI called StartDate and EndDate
I want to select data within those 2 dates.
I have tried 2 methods.
The first is
" DAY(V.RegDate) between " + Start.ToString("dd")
+ " and " + End.ToString("dd");
" and MONTH(V.RegDate) between " + Start.ToString("MM") + " and "
+ End.ToString("MM");
" and YEAR(V.RegDate) between " + Start.ToString("yyyy") + " and "
+ End.ToString("yyyy");
V.RegDate is the date column from the database.
But it returns me no data when I select 01/08/2010 and 01/09/2010 while there is some data at 25/08/2010.
I think that is because I chose the date separately and since the 2 dates are the same,
returns me nothing
I have tried another way...
" V.RegDate between #" + Start.ToString("dd/MM/yyyy") + "# and #" _
+ End.ToString("dd/MM/yyyy") + "#";
This also return me nothing
Any Ideas????
This pattern works for me:
SELECT sometable.somedate
FROM sometable
WHERE (((sometable.somedate) Between #2/1/2010# And #4/1/2010#));
(in this case it's MDY, I normally prefer ISO-ish style - YYYY/MM/DD because there is no way that Access can screw that up)
Maybe you've got your date set using the American default - MDY instead of the British(?) standard DMY.