实际上我已经在编辑模式下在gridview中限定了一个下拉列表,但问题是每当我尝试从下拉列表中选择另一个值时,它会自动选择第一个值。
我还在 page_load 事件上使用了 !IsPostBack 属性,但它仍然没有选择其他项目。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
DropDownList ddlCost_Code = DropDownList)e.Row.FindControl("ddlCost_Code");
BAL bl = new BAL();
DataTable dt_for_CostCode = null;
dt_for_CostCode = bl.Select_Cost_Code();
if (dt_for_CostCode.Rows.Count > 0)
{
ddlCost_Code.DataSource = dt_for_CostCode;
ddlCost_Code.DataTextField = "Cost_Code";
ddlCost_Code.DataValueField = "Proposalno";
ddlCost_Code.DataBind();
}
}
if (!IsPostBack)
{
try
{
Log_Booked_Info_Through_Booking_Table();
}
catch (Exception ex)
{
WebMsgBox.Show(ex.Message);
}
}
}