如何在gridview标题中添加行数信息? 我在设计源代码中编写此代码。但这不起作用。
<asp:GridView ID="gvData" runat="server" AutoGenerateColumns="false" HeaderStyle-BackColor="WindowFrame" Caption="Number of records: <%# gvData.Rows.Count %>">
答案 0 :(得分:1)
您应该使用OnDataBound事件:
protected void gvData_OnDataBound(object sender, EventArgs e)
{
gvData.Caption = $"Number of records:{gvData.Rows.Count.ToString()}";
}