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.
Related
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;
This question already has answers here:
How to get the referer search query from google?
(4 answers)
Closed 3 years ago.
I have this requirement: I need to save the search word made by a user who has come to my site.
The site is made in classic asp.
I have tried with:
Request.ServerVariables ("HTTP_REFERER")
Request.ServerVariables ("ALL_HTTP")
But I don't get the search query (q=) https://www.google.com/search?q=house
How can I get the value of q= ?
The following code will give you what you are looking for:
Response.Write(Split(Split(Request.ServerVariables ("HTTP_REFERER"), "?")(1),"=")(1))
For sure, you will need to adapt it : if you don't have query string, it will fail, and the parameter you are looking for needs to be the first one.
This question already has answers here:
Generate an HTML Response in a Java Servlet
(3 answers)
Show JDBC ResultSet in HTML in JSP page using MVC and DAO pattern
(6 answers)
Closed 2 years ago.
Suppose, I have updated my database by which I mean that I have inserted a new row of data in my database. Now, I want to edit my web page by that data how can I do this?
Suppose, I have three columns in my database "name", "picture" and "age" now I want to show the latest row of these columns in my HTML page with CSS applied. How can I do this please tell me the codes in terms of JSP and servlet.
First get that value in your servlets from database and then to show it in webpage
You can do two things :
Use request.setAttribute("id",value)
In the GET method of servlet,
request.setAttribute("name",value)
request.setAttribute("picture",value)
request.setAttribute("age",value)
And in the jsp, you can get these values as
request.getAttribute("name")
request.getAttribute("picture")
request.getAttribute("age")
Model
model.addAttriute("name",value)
Use JSTL library and then you get these values in jsp by:
${name}
${picture}
${age}
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
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()