Posts

Asp.net checkboxlist control

 we will learn about asp.net checkboxlist control. Just like DropDownList 1.  CheckBoxList is collection of ListItem objects. 2.  Items can be added to the CheckBoxList in the HTML source or in the code behind file 3.  CheckBoxList can be bound to a database table or an xml file DropDownList is generally used , when you want to present the user with multiple choices, from which you want him to select only one option. Where as if you want the user to select more than one option, then a CheckBoxList control can be used. Create an asp.net web application. Copy and paste the following HTML <asp:CheckBoxList ID="checkboxListEducation" runat="server"              RepeatDirection="Horizontal">     <asp:ListItem Text="Diploma" Value="1"></asp:ListItem>     <asp:ListItem Text="Graduate" Value="2"></asp:ListItem>     <asp:ListItem Text="Post Graduate" Value="3"></asp:

Cascading dropdown in asp.net

First create the required tables and populate them, with some sample data using the SQL  script below. Create Table tblContinents ( ContinentId int identity primary key, ContinentName nvarchar(50) ) Insert into tblContinents values ('Asia') Insert into tblContinents values ('Europe') Insert into tblContinents values ('South America')   Create Table tblCountries ( CountryId int identity primary key, CountryName nvarchar(50), ContinentId int foreign key references dbo.tblContinents(ContinentId) ) Insert into tblCountries values ('India', 1) Insert into tblCountries values ('Japan', 1) Insert into tblCountries values ('Malaysia', 1) Insert into tblCountries values ('United Kingdom', 2) Insert into tblCountries values ('France', 2) Insert into tblCountries values ('Germany', 2) Insert into tblCountries values ('Argentina', 3) Insert into tblCountries values ('Brazil', 3) Insert into tblCountries

Retrieving selected item text value and index of dropdownlist

we will discuss about retrieving the selected item text, index and value  from a dropdownlist. Let's first add some items to the dropdownlist. To do this 1.  Drag and drop a dropdownlist and a button control onto the webform 2.  Copy and paste the following HTML on the webform. <asp:DropDownList ID="DropDownList1" runat="server">     <asp:ListItem Text="Select Continent" Value="-1"></asp:ListItem>     <asp:ListItem Text="Asia" Value="1"></asp:ListItem>     <asp:ListItem Text="Europe" Value="2"></asp:ListItem>     <asp:ListItem Text="Africa" Value="3"></asp:ListItem>     <asp:ListItem Text="North America" Value="4"></asp:ListItem>     <asp:ListItem Text="South America" Value="5"></asp:ListItem> </asp:DropDownList> <br /><br /> <asp:Button ID="