Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. template field at runtime for detailsview

template field at runtime for detailsview

Scheduled Pinned Locked Moved ASP.NET
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    md_azy
    wrote on last edited by
    #1

    Hi , I am creating template field at runtime for detailsview . its working fine in view mode . but in edit mode nothing is showing in that field . TemplateField Field2 = new TemplateField(); Field2.HeaderText = "ClusterCode"; Field2.ItemTemplate = new AddTemplateToDetailsView (ListItemType.Item, "c_cluster_code"); DetailsView1.Fields.Add(Field2); public class AddTemplateToDetailsView : ITemplate { ListItemType _type; string _colName; public AddTemplateToGridView(ListItemType type, string colname) { _type = type; _colName = colname; } void ITemplate.InstantiateIn(System.Web.UI.Control container) { switch (_type) { case ListItemType.Item: DropDownList ht = new DropDownList(); ht.DataBinding += new EventHandler(ht_DataBinding); container.Controls.Add(ht); break; } } void ht_DataBinding(object sender, EventArgs e) { DropDownList lnk = (DropDownList)sender; DataTable dt = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["GoGreenVDCConnectionString"].ConnectionString,CommandType.Text,"select c_code,c_name from cluster_mst where n_deleted = 0" ).Tables[0] ; foreach (DataRow Row in dt.Rows) { lnk.Items.Add(new ListItem(Row[1].ToString().Trim(), Row[0].ToString().Trim())); } string str = lnk.NamingContainer.ToString() ; DetailsView container = (DetailsView)lnk.NamingContainer; lnk.SelectedValue = ((DataRowView)container.DataItem)["c_cluster_code"].ToString(); } }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups