Hi I was wondering how to go about populating a ddl inside a Grid Item Template Column from SQL. I tried doing it through the On Data Bound but I could not get it to work. Below is my code.
Thanks
Thanks
<asp:Panel ID="pnlGrid" runat="server" CssClass="panelGrid"> <telerik:RadGrid ID="myRadGrid" runat="server" Width="90%" Skin="Web20" CssClass="dvGridWrapper" AllowSorting="true" AllowPaging="true"> <PagerStyle AlwaysVisible="true" /> <MasterTableView AutoGenerateColumns="false" Font-Size="10" DataKeyNames="intRecruitId"> <HeaderStyle ForeColor="White" Font-Bold="true" HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center"/> <AlternatingItemStyle BackColor="#B0C4DE" HorizontalAlign="Center" /> <Columns> <telerik:GridBoundColumn DataField="dtRSPStatusChanged" HeaderText="Last Changed" /> <telerik:GridTemplateColumn HeaderText="NAME"> <ItemTemplate> <asp:LinkButton ID="lnkName" runat="server" Text='<%#Bind("Name")%>' CommandArgument='<%#Bind("intRecruitId")%>' CommandName="OpenForm" ToolTip="Click to See Data"></asp:LinkButton> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="PHASE"> <ItemTemplate> <asp:DropDownList ID="ddlPhase" runat="server"></asp:DropDownList> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="dtShip" HeaderText="SHIP DATE" /> <telerik:GridBoundColumn DataField="ddDate" HeaderText="DROP DEAD DATE" /> <telerik:GridBoundColumn DataField="dtProjReturn" HeaderText="EST RETURN DATE" /> <telerik:GridTemplateColumn HeaderText="STATUS"> <ItemTemplate> <asp:DropDownList ID="ddlStatus" runat="server" OnDataBound="ddlStatus_Load"></asp:DropDownList> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="ISSUE"> <ItemTemplate> <asp:DropDownList ID="ddlIssue" runat="server" OnDataBound="ddlIssue_Load"></asp:DropDownList> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="EDUCATION"> <ItemTemplate> <asp:DropDownList ID="ddlEd" runat="server"> <asp:ListItem Value="0" Text="N/A" /> <asp:ListItem Value="1" Text="HSSR" /> <asp:ListItem Value="2" Text="HSJR" /> <asp:ListItem Value="3" Text="GED +" /> <asp:ListItem Value="4" Text="GED" /> <asp:ListItem Value="5" Text="GRAD" /> <asp:ListItem Value="6" Text="COLLEGE" /> </asp:DropDownList> </ItemTemplate> <%-- SelectedValue='<%#Bind("intRSPStatusID")%>'--%> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="NOTES"> <ItemTemplate> <%-- <asp:Image ID="imgLooker" runat="server" ImageUrl="~/Images/ViewResources.gif" ImageAlign="Middle" BorderStyle="None" /> <asp:PopupControlExtender ID="popInfo" runat="server" PopupControlID="pnlPop" TargetControlID="imgLooker" DynamicContextKey='<% #Eval("strNotes")%>' DynamicControlID="pnlpop" DynamicServiceMethod="GetNotes" Position="bottom"></asp:PopupControlExtender>--%> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="strRSPSiteLocation" HeaderText="RSP SITE" /> <telerik:GridBoundColumn DataField="strUIC" HeaderText="UIC" /> <telerik:GridTemplateColumn HeaderText="UPDATE"> <ItemTemplate> <asp:LinkButton ID="lnkUpdate" runat="server" Text="Update" ToolTip="Click to Save Data"></asp:LinkButton> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView> </telerik:RadGrid> </asp:Panel> </asp:Content>
Code BehindProtected Sub ddlIssue_Load(sender As Object, e As EventArgs) Handles ddlIssue.Load sql = "Select strRSPIssueDesc from RSPIssue" ddlIssue.Items.Add(New ListItem("Select One", "0")) buildDD(sql, ddlIssue) End Sub Protected Sub ddlSite_Load(sender As Object, e As EventArgs) Handles ddlSite.Load sql = "select strRSPSiteLocation from RSPSite" ddlSite.Items.Add(New ListItem("Select One", "0")) buildDD(sql, ddlSite) End Sub Protected Sub ddlStatus_Load(sender As Object, e As EventArgs) Handles ddlStatus.Load sql = "Select strStatusType from RSPStatus" ddlStatus.Items.Add(New ListItem("Select One", "0")) buildDD(sql, ddlStatus) End Sub