Thursday, June 30, 2011

ASP.NET GridView usage

Дөнгөж үүсгэж байх үеийн Event дээр нь DropDownList нүдэнд өгөгдлийг нь өгөхийн тулд:

If you are now using a GridView. Please write something in the GridView_GridViewRowDataBound event and do this:
protected void GridView1_GridViewRowDataBound(object sender, GridViewRowEventArgs e)
{
 if(e.Row.RowType == DataControl.DataRow)
 {
  //Find the Dropdownlist
  Dropdownlist ddrList = (Dropdownlist)e.Row.FindControl("id of dropdownlist");
  ddrList.DataSource = PrimaryKeys from the "Column" class.
  ddrList.DateTextField = "xxx";
  ddrList.DataValueField = "yyy";
  ddrList.DataBind();
 }
}

No comments: