GridView数据绑定不工作
本文关键字:工作 数据绑定 GridView | 更新日期: 2023-09-27 17:59:50
我有一个网格视图,它有一个对象列表的数据源。但它似乎在DataBind步骤中出现了问题。它不会在网站上显示任何内容。
List<StringTR> strResult_List = new List<StringTR>();
foreach (TSService.STs ST in ST_Returned_list) //I'm converting ST_Returned_list to StringResult as ST_Returned_list has some custom type fields and they are not working with Gridview
{
strResult_List.Add(new StringResult(ST));
}
ResultsGridView.DataSource = strResult_List;
ResultsGridView.DataBind(); // this is where it is failing. when I step through it, it says "Step into: Stepping over method without symbols"
public class StringResult
{
string str_SName { get; set; }
string IPAddressUsed { get; set; }
string BTypeUsed { get; set; }
string SResult { get; set; }
public StringResult(TestScriptsService.Sel_Test ST)
{
str_SName = ST.SName.ToString();
IPAddressUsed = ST.IPAddressUsed;
BTypeUsed = ST.BTypeUsed.ToString();
SResult = ST.SResult.ToString();
}
}
在数据绑定步骤中放置一个断点,并检查数据源中的内容。这将消除疑虑。