variable name with a white space [closed] - c#

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to have a variable name with a white space.
Am passing this collection to a gridview and i need the title to have a white space instead of an underscore
var registrationReport = (from r in BankMedEntity.Customers
select new {r.Id,Customer Type = r.CustomerType_Id });
Any idea on how i can accomplish that?
I need to have the title as "Customer Type" instead of "CustomerType_Id"

You cannot, c# does not allow spaces in variable names. They would be considered different words and the compiler will go "Ahh...What do you mean?"

Turn this to false
AutoGenerateColumns="True"
And add your own Bound columns to the Gridview. You will be able to give the columns whatever names you want

Unfortunately that is impossible; the compiler has no way of figuring out that the two separate words are actually part of the same variable name.

No space is allowed in variable name.
If you want the title of the gridview with no underscore, you should edit the girdview definition in .aspx file.

Related

How to add a wiki page through ItemAdded event receiver coding on the addition of a new item in a list? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have a list named 'List1' in which I have 'title ' and 'WikiLink' columns. I want to add a wiki page on the addition of a new item using ItemAdded event receiver code and update the link on 'WikiLink' column. Please help me out in this. I have been stuck on this for quite a while.
Thanks.
To create wiki page, you will have to add new item into one of the libraries that accepts wiki pages. Typically it's Site Pages, with code more less like this:
var l = (SPDocumentLibrary) SPContext.Current.Web.Lists["Site Pages"];
var folder = l.RootFolder;
var f = folder.Files.Add(string.Format("{0}/{1}", folder.ServerRelativeUrl.TrimEnd("/"), "MyWiki.aspx"), SPTemplateFileType.StandardPage);
//Site Absolute url + Site-relative Url, more info on MSDN.
var url = string.Format("{0}/{1}", SPContext.Current.Site.Url.TrimEnd("/"), f.Url);

WPF FlowDocument layout [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a FlowDocument in which I need to insert many fragments of dynamic text at arbitrary positions.
For example, I need to place text "Hello" at x = 10, y = 15 and text "World" at x = 10, y = 20.
I'm currently doing this using Figure. I create a Run with the text, put it in a Paragraph, and put all that in a Figure. From there I can set it's VerticalOffset and HorizontalOffset. Then I place all the figures in a Paragraph which I add to the FlowDocument.
Everything was going OK (it was the simplest approach I could came up) until I had to place two or three fragments of text on the same line (at the same y but different x).
For some reason it's putting each Figure on a new line instead of putting them all in the same line, let me illustrate:
Expected:
text1 text2 text3
Actual:
text1 text2 text3
Does anybody know how to remove that line break between figures? If you have a better approach to this problem I'm open to suggestions too.
I ditched FlowDocument and went with XAML and used a Canvas... made my life much easier being able to place all text fields visually... much easier to maintain in the long run too.

Changing date-time format in c# [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Creating digital clock. I'm newbie to C#. My code look like that
timeLbl.Text = DateTime.Now.ToLongTimeString();
dateLbl.Text = DateTime.Now.ToLongDateString();
Here is, the result
http://content.screencast.com/users/TT13/folders/Jing/media/da6d1f65-bf5f-4735-97dc-70485112a998/2012-07-02_1826.png
I got some questions:
Can I change time's format to 24 Hour? how?
How to change date into digits only format (like dd/mm/yyyy) or this result but in exact language (I mean, words "Monday, July" in another language, which windows support, for ex Turkish)?
How to make window dynamically change it's width (depending on text
length)?
Please help me,to achieve these 3 things. Thx in advance
Ans 1:
timeLbl.Text = DateTime.Now.ToString("HH:mm:ss");
Will convert time to 24 hour format.
Ans 2:
dateLbl.Text = DateTime.Now.ToString("dd/MM/yyyy");
Will convert date format to 31/06/2012
More formats here
The first and second point where been answered, for the last point set SizeToContent="WidthAndHeight" on the window and the window will dynamically resize based on its content size. I assume ur working with wpf, else it doesnt works!

Linq to find the length of the value of the column in the list [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a list and a column; the column might have many values, and each value's length may vary.
If the length exceeds 100, I want to append /n at the end of it.
Need your help.
I give it a try, though a lot of questions are open (what type of list, what a column, ...).
In short: you can use String.Insert to insert text at a specified postition.
Assuming you have a List<Foo>, the class Foo has a string property Value (your column). If it's Length exceeds 100 the line should be wrapped:
foreach(Foo foo in foos)
{
if(foo.Value.Length > 100)
foo.Value = foo.Value.Insert(100, Environment.NewLine);
}
http://msdn.microsoft.com/en-us/library/system.string.insert.aspx
Here's running code with sample data.
http://ideone.com/sUKLk

How can I change the stock in a Microsoft Access database? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I'm having a problem altering the stock in my database. What I am looking to do is to minus the stock in my database by 1 when the button 'Reserve Item' is clicked on. So say the stock is sitting at 10. When I reserve an item I want the stock in the database to automatically decrease to 9.
Any ideas on how this can be achieved Using ASP.NET with C#?
Even shorter:
update stock_table
set stock_quantity = stock_quantity - 1
where stock_id = xxx
The SQL UPDATE statement
What you really want to do is something like this:
UPDATE stock_table
SET stock_quantity = (SELECT stock_quantity - 1 FROM stock_table WHERE stock_id = '#####')
WHERE stock_id = '#####'
'######' presents the id of your item (not sure if you are using int or varchar/text or guid).

Categories