开发者

How to Bind Data in HTML Drop Down List

Can any one please tell me How to Bind Data from Sql D开发者_Go百科ataBase to DropDown List(Select Drop Down) using C#.net in Asp.net


OK! first youll have to write the javascript code using HTML in the client side using the selectedIndex function! you could read more about javascript in google , second you you bind your data in server side like this

dropdown1.DataSource = datatable; dropdown1.DataBind();

OR read these links

http://shawpnendu.blogspot.com/2009/08/javascript-how-to-get-selectedtext-from.html

http://shawpnendu.blogspot.com/2009/05/how-to-bind-or-populate-data-into.html

i hope it helps you or at least show you the right directions or hints of what you want :)


Try this one ...you can achieve it

<script type="text/javascript">
            function func() {
                var grd = document.getElementById("Panel1");
                grd.setAttribute("style", "display:inline;");
            }
        </script>
    <asp:TextBox ID="txtDDL" CssClass="txtClass" runat="server" ReadOnly="true" onclick="javascript:func();" />
                <asp:Panel ID="Panel1" runat="server" Style="display: none;">
                    <asp:GridView ID="GridView1" runat="server" BackColor="LightGoldenrodYellow" BorderColor="Tan"
                        BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None">
                        <AlternatingRowStyle BackColor="PaleGoldenrod" />
                        <FooterStyle BackColor="Tan" />
                        <HeaderStyle BackColor="Tan" Font-Bold="True" />
                        <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                        <SortedAscendingCellStyle BackColor="#FAFAE7" />
                        <SortedAscendingHeaderStyle BackColor="#DAC09E" />
                        <SortedDescendingCellStyle BackColor="#E1DB9C" />
                        <SortedDescendingHeaderStyle BackColor="#C2A47B" />
                        <Columns>
                            <asp:TemplateField HeaderText="Select">
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkSelect" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                    <asp:LinkButton ID="lbtnSelect" Text="Check All" runat="server" OnClick="Select"  />
                    <asp:Button ID="btnSubmit" CssClass="btn" Text="Submit" runat="server" OnClick="Result"  />
                    <asp:LinkButton ID="lbtnClear" Text="Clear All" runat="server" OnClick="Clear"></asp:LinkButton>
                </asp:Panel>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜