1
iam在嘗試在asp.net中創建下拉列表時發生錯誤。希望你們可以幫忙,因爲我不知道還有什麼其他的嘗試了..
錯誤:「system.data.datarowview'不包含名爲'Suppstatus'的屬性。」,聽起來像是拼寫錯誤,但ive tripple檢查。Gridview,system.data.datarowview'不包含屬性
模板代碼:
<asp:TemplateField>
<ItemTemplate>
<asp:Label Text='<%#Eval("Suppstatus") %>' Visible="false" ID="lblsuppStatus" runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList runat="server" ID="ddlSupStatus"> </asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
後面的代碼:
protected void grvSupplierStatus_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow && GridView1.EditIndex == e.Row.RowIndex)
{
DropDownList ddlSupStatus = (DropDownList)e.Row.FindControl("ddlSupstatus");
Label lblsuppstatus = (Label)e.Row.FindControl("lblsuppStatus");
DataSet ds = new DataSet();
ds = GetYesNoValue("Suppstatus");
DataTable dt = new DataTable();
dt = ds.Tables[0];
ddlSupStatus.DataSource = dt;
ddlSupStatus.DataTextField = "Suppstatus";
ddlSupStatus.DataValueField = "Suppstatus";
ddlSupStatus.DataBind();
ddlSupStatus.Items.FindByValue(lblsuppstatus.Text).Selected = true;
}
}
catch (Exception ex)
{
}
}
public DataSet GetYesNoValue(string ColumnName)
{
DataTable dtVal = new DataTable();
DataColumn column;
DataRow row;
column = new DataColumn();
column.DataType = System.Type.GetType("System.String");
column.ColumnName = ColumnName;
dtVal.Columns.Add(column);
DataSet dsVal = new DataSet();
dtVal.Rows.Add("--Select--");
dtVal.Rows.Add("Yes");
dtVal.Rows.Add("No");
dsVal.Tables.Add(dtVal);
return dsVal;
}
是啊是我想要的,無法找到它的任何信息,感謝的人你就是老闆。 –
太好了,不客氣 – fubo