I have confusing on adding dropdownlist into datagrid, here some references about that:
- http://www.codeproject.com/useritems/DatagridWithDropdown.asp
- http://www.gridviewguy.com/ArticleDetails.aspx?articleID=71
- http://www.velocityreviews.com/forums/t93920-selectedindex -of-dropdownlist-in-datagrid.html
- http://www.codeproject.com/aspnet/DataGridDropDownList.asp
- http://www.odetocode.com/Articles/231.aspx
- http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/ html/vbtchTopQuestionsAboutASPNETDataGridServerControl.asp
And now, i’m still in confusing to pick index of the selected record and associate into dropdownlist. I’ll try it again….
Update:
Here the code to associate index of dropdownlist:
/// /// Set Selected Item into combo /// /// /// private void DtDetail_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if(e.Item.ItemType == ListItemType.EditItem) { DataRowView drv = (DataRowView) e.Item.DataItem; String code = drv["Code"].ToString(); DropDownList ddl = (DropDownList) e.Item.FindControl("cmbItem"); ddl.SelectedValue = code.Trim(); //manipulate width all textbox (using static variable) for (int i=0;i string ctl = "_ctl" + i.ToString().Trim(); TextBox txtB1 = (TextBox) e.Item.FindControl(ctl); txtB1.Width = 50; } } }