.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

jQuery: Styling DropDownList Alternating Items (Rows)

Posted By: Amit Mehra     Posted Date: November 16, 2009    Points: 2   Category :ASP.Net
In the following example, I will show how you can style any asp:dropdownlist very easily.

The example demonstrates how you can change alternating row items background color, using the fadeTo() to add a nice touch in the dropdownlist. You can change alt rows with a couple lines.

View Complete Post

More Related Resource Links

jQuery: Highlight Gridview Rows with Checkbox

Im learning and experimenting with jQuery and ASP.NET. Below is a simple solution I created to highlight rows in a gridview by clicking on a checkbox next to the row.

Gridview setup:

jQuery: Highlight Gridview Rows with Checkbox

Im learning and experimenting with jQuery and ASP.NET. Below is a simple solution I created to highlight rows in a gridview by clicking on a checkbox next to the row.

How to format and update GridView and DataGrid rows using JQuery

The behavior described in this question is as expected. When you set text of a cell in grid, it directly affects HTML that is going to be rendered. When you set text value of a cell, it means that you are setting innerText of the cell. The column that GridView creates for command fields (Edit, Delete and Select) are a (anchor) or button elements. So you can see what will happen if you set text value in that cell. It will wipe out those link or button controls and replace them with simple text string.

Using jQuery to Filter Table Rows

The project is using the .net GridView control, so I had limited control over the output HTML code. Still, I think this code can work for most tables. One thing to notice: you should use the class "filterable" on your table or on one of its parents for the code to work.
First, we need a text box:

styling dropdownlist problem


Dear All,

im facing a problem while styling my ddl, what i did is:

<div><asp ropDownList ID="DropDownList1" runat="server" style="background-color:Transparent;" Width="100%">
    </asp: dropDownList></div>

<div class="stlGradient">
<asp ropDownList ID="DropDownList1" runat="server" style="background-color:Transparent;border:none;" Width="100%"></asp: dropDownList>

the DIV style is having a bg image repeated X.

now this worked on Firefox
on google Chrome: the border gone but the background still white
on IE 7: nothing happend

thanks for helping.

How to handle Active and inactive items in the dropdownlist?


It is a general ASP.NET questions. Many times some items in dropdownlist will become inactive (retired)or active again. It is easy to handle in the new records which use only currently active items. But how to handle the inactive items which need to be used to show history records. It bothered me a long time, not sure how to solve this problem efficiently.


dropdownlist javascript change items


I can't find solution for this problem for very long time:

I have dropdownlists in Gridview. I need to dinamicly change content of dropdown on client with javascript. Ok, I know to do that. But the problem is when I send data to server changes in dropdownlist does not see. On server I have  old items. How can I change items in dropdown on client with javascript and than see that items on sever when postback data?


dropdownlist bound to sqldatasource adds items instead of replacing on change



I have a series of dropdownlists on webform in ASP 4.0. The first drop down is filled upon load, and then when a user selects a value from that list, it populates the second dropdown. To accomplish this, I have a SQLdatasource with a parametersource of the first drop-down list control. This works great, except when a user changes their selection from the first drop down. It performs the query, but then adds the list of items to the ones that were already there from the previous selection, instead of replacing it with the new data. Here is the code:

 <asp:DropDownList ID="ddlMajor" runat="server" DataMember="DefaultView" 
      DataSourceID="SqlDataSource1" DataTextField="majortext" 
      DataValueField="majorkey" AppendDataBoundItems="True" AutoPostBack="True">
         <asp:ListItem Value="0">Select Major</asp:ListItem>
<asp:DropDownList ID="ddlReq" runat="server" DataMember="DefaultView" 
      DataSourceID="SqlDataSource2" DataTextField="req" DataValueField="admreqkey" 
            AppendDataBoundItems="True" AutoPostBack="True">
                <asp:ListItem Value="0">Sel

Cannot count number of checked items using jQuery

Hello,Using Microsoft built-in jquery files, when counting numbers of checked checkbox, the jquery-1.4.2.min.js cannot count the correct result ,however, the version jquery-1.3.2.min.js gives out the correct one, why?            $("#check").click(function () {                var nameSports = new Array();                var i = 0;                $('input[name=selector]:checked').each(function () {                    nameSports[i] = jQuery(this).val();                    i += 1;                });                if (loopCounter != 0) {                    alert(i);                }  

Get dropdownlist event OnSelectedIndexChange using jquery

I have dropdownlist that located inside a repeater, how can i get OnSelectedIndexChange event of this dropdownlist? i want to use this event to set TextBox value olso inside this repeater, i try this code$("#Table1> tbody > tr ").each(function() { var rowId = $(this).attr("id"); $(this).find("td > #DropDownList1").change(function() { $("#" + rowId + "> TD:nth-child(6) > input[name$='TextBox1']").val("Test"); }); }); But did not work, can anyone please help me?

JQuery with dynamic ASP.NET controls (DropDownList)

I am mixing JQuery with ASP.NET webforms.  Adding dynamic controls and accessing the selected values with JQuery works differently under different circumstances and I am trying to establish the difference. Why does Senario 1 work in debug mode but not without breakpoints?  What does databinding to a GridView do that adding DropDownList controls to a asp:panel does not? Is there some sort of DOM registration going on in DataBind? All senarios use the same JQuery: var ddlCollection = $("select[name$='ddlDynamicDropDown']") Senario 1: Breakpoints on each line (Success) Add DropDownList controls to a asp:panel dynamically in the PageLoad method (Does the page lifecycle matter? OnLoad method instead?). Run the code Select values and click on a button firing a JavaScript function (Break in Debug) Break in JavaScript file Access the dropdowns and their selected values successfully Senario 2:  Run the Senario 1 code without breakpoints (Fails to locate the ddlCollection) Senario 3: Use a GridView (Success) Add values to populate the DropDownList controls to a Generic List. Bind the values to a GridView control containing the DropDownList controls Run the code Select values and click on a button firing a JavaScript function Use JQuery to Access the dropdowns and their selected values successfully.  

Need advice on preformance (web service returns list items on 20000 rows list)

Greetings I need to write a web service that will return sharepoint list items (default web services of sharepoint are no use to me since they just suck when the site is not in english).  Since we have lists with 20k+ items, the return xml might get large. Query web service did manage to do it, yet it took some time to output the xml with those 20k rows.  I am affraid that my custom made web service will preform poorly since it wont be "native" to sharepoint. I am asking for your judgement, did i fell into common pitfalls or something or is there any way to improve preformance of my code? My own web service code looks like this:   [WebMethod] public XmlDocument GetListItems(string siteurl, string listguid,string querytext,string rowlimit) { InitSchemaExporter(siteurl); SPQuery query = new SPQuery(); query.RowLimit = rowlimit.Length==0?10:Convert.ToUInt32(rowlimit); query.Query=querytext; return SchemaExporter.GetListItems(listguid, query); } public void InitSchemaExporter(string siteurl) { SchemaExporter.SetSite(siteurl); SchemaExporter.IgnoreField = ConfigurationSettings.AppSettings["IgnoreField"].Split(new string[1] { "\r\n" }, System.StringSplitOptions.None).ToList<string>(); ; SchemaExporter.IgnoreList = ConfigurationSettings.AppSettings["IgnoreList"].Split(new string[

Order of the items in a DropDownList inside GridView



I have a DropDownList inside the EditTemplateItem (if the user clicks edit) in a GridView. The DropDownList receives all available rows from the database.

My problem is, if the user clicks Edit in the GridView to edit a row and opens the DropDownList Box the original item is not selected but the first one. That means the items are sorted.

Have someone an idea how I can solve this issue that the right item / the original is selected if I change to edit mode of the grid view?

The only idear that I have is to write some lines in the code behind for the updating event and selected the suitable index manually but I think there must be an easier way.


Html.DropDownList items with '<'


 How do I tell asp.net to display escape characters in a 



In the select list, there are some '>' and '<'. I used &lt; and &gt; but the page shows &lt; and &gt; instead of '<' and '>'.

Any help?


set selected value after jQuery populated Dropdownlist



i'm using jQuery to populate an cascading dropdownlist. But i want to set a selected item after jQuery filled the DDL with items.

How do i do that?


MVC Json and Jquery with dropdownlist


 Dear all,

I want to do like below:

I have three dropdownlist:

- test

- test1

- test2

and i have two textbox

 - txtname

- txtsex

when i click on test dropdown list i want to diplay data in test1 dropdownlist and display in txtname and txtsex too, how can i do by using mvc json and jquery ?

'Dropdownlist' has a SelectedValue which is invalid because it does not exist in the list of items


I have a dropdown list that has a bind on it and I get this error. Why am I getting this error and what can I do to fix it. here is the code for the dropdown I currently have:


 <asp:DropDownList  ID="DDLPreferred" AppendDataBoundItems="true" SelectedValue='<%# Bind("PREFERRED_COMMUNICATION") %>'  runat="server" TabIndex="15">
                <asp:ListItem Text="none" Value=""></asp:ListItem>

				<asp:ListItem>Home Phone</asp:ListItem>
				<asp:ListItem>Work Phone</asp:ListItem>
				<asp:ListItem>Cell Phone</asp:ListItem>


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend