code_junkie

grid view combobox

Nov 13th, 2011
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <asp:GridView ID="GridView1" runat="server" OnRowCreated="GridView1_RowCreated">
  2. <Columns>
  3. <asp:TemplateField HeaderText="Prerequisite Course">
  4. <ItemStyle HorizontalAlign="Center" />
  5. <ItemTemplate>
  6. <asp:DropDownList ID="ddlPrerequisiteCourseCode" runat="server">
  7. </asp:DropDownList>
  8. </ItemTemplate>
  9. </asp:TemplateField>
  10. </Columns>
  11. </asp:GridView>
  12.  
  13. protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
  14. {
  15.  
  16. if (e.Row.RowType == DataControlRowType.DataRow)
  17. {
  18. // Bind drop down to PrerequisiteCourseCodes
  19. DropDownList ddl = (DropDownList)e.Row.FindControl("ddlPrerequisiteCourseCode");
  20. ddl.DataSource = PrerequisiteCourseCodeList;
  21. ddl.DataBind();
  22. }
  23.  
  24. }
Add Comment
Please, Sign In to add comment