开发者

C# ERROR: Gridview Row count

i want to display the count of grid view

can anyone tell me what i did wro开发者_运维问答ng in this code

protected void Page_Load(object sender, EventArgs e)
{

    gridview1.DataSource = Session["dsource"];
    gridview1.DataBind();
    Response.Write(gridview1.Rows.Count.ToString);

}    

the error appears in the response.write line


ToString is a method, not a property.

Response.Write(gridview1.Rows.Count.ToString());

Of course, you could always use the version that will call ToString() for you.

Response.Write(gridview1.Rows.Count);


In this case you can delete ToString. 'gridview1.Rows.Count' will be automaticly converted to string.

If you want to leave ToString you need () in the end, ToString(). It's a method.

Best regards, Dima.


You need extra ():

   Response.Write(gridview1.Rows.Count.ToString());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜