ASP.NET - SPLessons

ASP.NET Data Binding

Home > Lesson > Chapter 12
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

ASP.NET Data Binding

ASP.NET Data Binding

shape Description

The ASP.NET Data Binding is the process to bind a set of data under one option. In ASP.NET, there are few controls which are used to provide a set of specific data to the user. Where, the data source can be one external database or data can be added at the property level itself of those controls. Few of these controls are mentioned with examples

shape Example

Controls with examples.

ListBox

shape Syntax

[html]<asp:ListBox ID="ListBox1" runat="server"> <asp:ListItem Value="0">One to One</asp:ListItem> <asp:ListItem Value="1">Short Term</asp:ListItem> <asp:ListItem Value="2">Class Room Training</asp:ListItem> </asp:ListBox>[/html] Above code will result in like below screenshot

shape Syntax

[html]<asp:DropDownList ID="spddlStream" runat="server"> <asp:ListItem Value="0">Please select</asp:ListItem> <asp:ListItem Value="1">Asp.net</asp:ListItem> <asp:ListItem Value="2">C#</asp:ListItem> <asp:ListItem Value="3">Vb.net</asp:ListItem> <asp:ListItem Value="4">jQuery</asp:ListItem> <asp:ListItem Value="5">JavaScript-</asp:ListItem> <asp:ListItem Value="6">HTML</asp:ListItem> <asp:ListItem Value="7">CSS</asp:ListItem> <asp:ListItem Value="8">AJAX</asp:ListItem> </asp:DropDownList>[/html] Above code will result in like below screenshot

CheckBoxList

shape Syntax

[html] <asp:CheckBoxList ID="spcbTechnology" runat="server"> <asp:ListItem Value="0">ASP.NET</asp:ListItem> <asp:ListItem Value="1">Java</asp:ListItem> <asp:ListItem Value="2">VB</asp:ListItem> <asp:ListItem Value="3">Unix</asp:ListItem> <asp:ListItem Value="4">SQL</asp:ListItem> </asp:CheckBoxList>[/html] Above code will result in like below screenshot

RadioButtonList

shape Syntax

[html] <asp:RadioButtonList id="spRadioButtonList" runat="server"> <asp:ListItem value="A" text="Android" /> <asp:ListItem value="I" text="IOS" /> <asp:ListItem value="B" text="Blackberry" /> <asp:ListItem value="O" text="Other" /> </asp:RadioButtonList> [/html] Above code will result in like below screenshot