How to populate a dropdownlist with all countries? [duplicate] - asp.net

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Where can I get a list of all countries/cities to populate a listbox?
I'm trying to fill my dropdownlist with all world countries from windows, is there any way to make my dropdownlist get all countries from windows?
Or do anybody have a XML with all the list so I can use it?

Update 8/9/2016:
List of Countries
Just did a quick search and found this site:
http://madskristensen.net.web7.reliabledomainspace.com/post/XML-country-list.aspx.
Here's the direct link to the file:
http://cid-247fb0008340dbcd.office.live.com/self.aspx/workstion/countries.xml
Update: Code to populate your drop down list with the list of countries:
Dim doc = XDocument.Load("path to url\file")
Dim countries = From c in doc.Descendants("country")
Select c.Value
For Each country In countries
DropDownList.Add(country)
Next
DropDownList.DataBind()

Related

1. How to avoid Red Cross in DatagridView C#.net windows form? [duplicate]

This question already has answers here:
C# red cross in datagridview
(2 answers)
Closed 1 year ago.
I am using a gridview which updates values periodically as well as automatically(based on autorefresh timer)
My Problem is that I get a Big Red Cross over my gridview.
http://koenaerts.ca/wp-content/uploads/dgvredx.png
if (gridView.InvokeRequired)
gridView.Invoke(new MethodInvoker(() => gridView.DataSource =YOUR_DATASOURCE));
else
gridView.DataSource = YOUR_DATASOURCE;

Firebase "like" search on string [duplicate]

This question already has answers here:
How to perform sql "LIKE" operation on firebase?
(5 answers)
Closed 5 years ago.
I am trying to search the user on the basis of name . It search perfectly if the name is given from first name but didn't search on the string the second name. Where first and second both are saved in one value separated by space for example
"John Smith". If search on "john" or "jo" etc it retrieve the record but if its smith it retrieve nothing.
Code
var ref = firebase.database().ref().child('User').orderByChild("name").startAt(searchString).endAt(searchString + "\uf8ff");
$scope.usercollection = $firebaseArray(ref);
With your query it is normal that you only get results starting with j, jo, joh, john, etc... The startAt method "creates a Query with the specified starting point". So it looks at how your searchString variable starts.
There is no full text search mechanism in Firebse for the moment. You will find on the web several possibilities to implement such a mechanism, e.g.:
https://firebase.googleblog.com/2014/01/queries-part-2-advanced-searches-with.html
https://github.com/FirebaseExtended/flashlight

Asp.net DropDownlist with headers [duplicate]

This question already has answers here:
Dropdownlist control with <optgroup>s for asp.net (webforms)?
(12 answers)
Closed 8 years ago.
I need to display drop down list with headers
values are retriving from database
i need to display like
Maharashtra
Mumbai
Nasik
Pune
UttarPradesh
Lucknow
Meerut
Noida
Ghaziabad
Uttrakhand
Dehradun
Rishikesh
Haridwar
<asp:DropDownList> does not directly support the use of <optgroup>. You will need to ether implement your own control or use an adapter. Here is one such example: http://www.codeproject.com/Articles/15505/ASP-NET-DropDownList-with-OptionGroup-support
Another option is to use only <option> elements, but instead add fake-indent by adding extra (visible) whitespace prefixed to the Text of each ListItem.

How do I show "NEXT" x items to the user? [duplicate]

This question already has answers here:
Paging & Sorting grids with ASP.Net MVC
(5 answers)
Closed 9 years ago.
I am learning MVC. I'm creating a simple website for demo, which stores products in Database and shows them to the user 10 per page. Now, how do I fetch "NEXT" 10/20 items from the database? I thought of adding auto-increment column to table and then fetching items on its basis. Is it the right way? Also I am keeping record of how many items have been shown to the user by getting an int value as parameter to the Controller function, Products(int id). Is it the right way? I mean will it work if user is on 5th page(hence id==5) and refreshes the page?(or will it set id back to 0?).
you can use linq queries to fetch number of items in a table. you can pass number of item, start index. then the query will be like this
var nextProduct = myProducts.Skip(100).Take(10);
it will return 10 items from 101 to 110.
Fetching data based on id is not a good idea. because if u delete any record there will be a difference in the count and id. so you can take using the above code concept

How do I display data in asp.net that has follows a specific pattern/ format?

I have this table
and what I want to is have something like this on the browser.
The table has 8 rows and 3 columns
Here's my sql query: "SELECT q.QuestionID, q.QuestionText, q.GroupNo FROM question q ORDER BY GroupNo asc"
I have already stored the questions but I'm having a hard time printing it in this format.
Wherein after printing 4 questions it will then go to another cell and print 4 questions again and then once there are already 3 columns it will then create a new row and do the same step again.
[ In the database the 1st 4 questions are QuestionID1,2,3,4 and then the cell on it's right are 6,7,8,9 and so on....]
I want to display the questions in this pattern.
I'm stuck with this for almost two days already.... I tried looking for other solutions online but I wasn't able to find something that is quite similar with what I'm trying to accomplish. I'm trying to do it with either datalist or a repeater. If you could provide a solution that uses both it would be of really++ great help
Sir/Ma'am your answers would be of great help. Thank you++
I think you should give up the existing controls like repeater or datalist.Just use your own code to implement this function.Maybe like this:
StringBuilder sb=new StringBuilder();
for(int i=0;i<4;i++)
{
sb.append("...");
}
sb.append("...");
for(int i=4;i<8;i++)
{
sb.append("...");
}

Resources