Friday, February 5, 2016

Add a select row at the top of a drop down list



[code] DataTable tableItem = new DataTable(); tableItem = jobCardService.loadAllItems(); if (tableItem.Rows.Count > 0) { DataRow row = tableItem.NewRow(); row["ItemCode"] = "--------- Select --------"; row["ListId"] = "-1"; tableItem.Rows.InsertAt(row, 0); ddlItem.DataSource = tableItem; ddlItem.DataTextField = "ItemCode"; ddlItem.DataValueField = "ListId"; ddlItem.DataBind(); } [/code]

No comments:

Post a Comment