<script type="text/javascript" language="javascript"> $(document).ready(function (e) { InitializeDDL(); }); function InitializeDDL() { try { $('#<%=GridProcessFlow.ClientID %>').find('.clsddl').msDropDown(); } catch (e) { alert(e.message); } } </script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <script type="text/javascript"> Sys.Application.add_load(InitializeDDL); </script> <asp:Panel ID="pnlTabBoxProcess" runat="server"> <asp:GridView ID="GridProcessFlow" runat="server" OnRowCommand="GridProcessFlow_RowCommand" OnRowDataBound="GridProcessFlow_RowDataBound"> <Columns> <asp:TemplateField HeaderText="Legends" ItemStyle-CssClass="WrappedText"> <ItemTemplate> <asp:DropDownList ID="ddlLegends" runat="server" Width="100px" AutoPostBack="false" OnSelectedIndexChanged="ddlLegends_SelectedIndexChanged" CssClass="clsddl"></asp:DropDownList> </ItemTemplate> </asp:TemplateField> </asp:GridView> </asp:Panel> </ContentTemplate> </asp:UpdatePanel>
protected void GridProcessFlow_RowDataBound(object sender, GridViewRowEventArgs e) { DropDownList ddlLegends = (DropDownList) e.Row.FindControl("ddlLegends"); SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=MySampleDB;Integrated Security=true"); con.Open(); SqlCommand cmd = new SqlCommand("select * from Legends", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); ddlLegends.DataSource = ds; ddlLegends.DataValueField = "LegendImage"; ddlLegends.DataTextField = "Legend"; ddlLegends.DataBind(); if (ddlLegends != null) { foreach(ListItem li in ddlLegends.Items) { li.Attributes["title"] = "Images/Legends/" + li.Value; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)