加上runat="server"属性 后台就可以用id来控制了
<div id="div1" runat="Server">
...
</div>
if(GridView1.Rows.Count > 0)
{
div1.Style["Display"] = "Block"; //显示
}
else
div1.Style["Display"] = "None"; //隐藏