當我使用沒有擴展方法屬性如何解決它
protected void GenGridView()
{
var data = project.ObtainDataDescJSON();
Title = "show";
for (int rowCtr = 0; row < data.Num.Count; row++)
{
var buttonField = new ButtonField
{
ButtonType = ButtonType.Button,
Text = "Show",
CommandName = "Display"
};
buttonField.Attributes.Add("data-toggle", "modal");
buttonField.Attributes.Add("data-target", "#myModal");
buttonField.CssClass = "btn btn-info";
ModelNumFieldsGrid.Columns.Add(buttonField);
break;
}
}
在C#中定義按鈕我有錯誤說沒有擴展屬性和沒有擴展名的CssClass。
我試圖
[AttributeUsageAttribute(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
public sealed class ExtensionAttribute : Attribute
和
using System.Runtime.CompilerServices.ExtensionAttribute;
,但不起作用。我該如何解決呢
我確切的錯誤,
Error \t 2 \t 'System.Web.UI.WebControls.ButtonField' does not contain a definition for 'Attributes' and no extension method 'Attributes' accepting a first argument of type 'System.Web.UI.WebControls.ButtonField' could be found (are you missing a using directive or an assembly reference?) \t C:\Users\s0\Documents\Visual Studio 2013\WebSites\Model.aspx.cs \t 55 \t 25 \t Pred
Error \t 7 \t 'System.Web.UI.WebControls.ButtonField' does not contain a definition for 'CssClass' and no extension method 'CssClass' accepting a first argument of type 'System.Web.UI.WebControls.ButtonField' could be found (are you missing a using directive or an assembly reference?) \t C:\Users\s06\Documents\Visual Studio 2013\WebSites\Model.aspx.cs \t 74 \t 25 \t Pred
你能告訴我們'buttonField'的定義嗎? –
酷!讓我更新我的帖子 –
實際的錯誤信息也會有所幫助 - 我敢肯定這不是「沒有擴展屬性,也沒有擴展cssClass」 –