Wednesday, December 8, 2021

SQLDatasource in Dropdown list in asp.net C#

  <asp:SqlDataSource ID="SqlDataSource1" runat="server" 

                ConnectionString="<%$ ConnectionStrings:test %>" 

                SelectCommand="SELECT [ID], [Name] FROM [Customer]"></asp:SqlDataSource>


<asp:DropDownList runat="server" ID="ddlState" 

                     AppendDataBoundItems="True" DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="ID">

                    <asp:ListItem Text="yash" Value="0" ></asp:ListItem>

                    <asp:ListItem Text="naveen" Value="1"></asp:ListItem>

                    <asp:ListItem Text="demo" Value="2"></asp:ListItem>

                </asp:DropDownList>

No comments:

Post a Comment