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());
精彩评论