protected void gvuser_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)//数据行
{
string ipStr = e.Row.Cells[3].Text; //第3列IP地址
Image tmp_Image = (Image)e.Row.Cells[4].FindControl("Image1");//第4列图片显示模板列
Ping pingSender = new Ping();//using System.Net.NetworkInformation
PingReply reply = pingSender.Send(ipStr, 120);//第一个参数为ip地址,第二个参数为ping的时间
if (reply.Status == IPStatus.Success)
{
networkFlag = true;//当ping IP地址通时,显示Shell32 019图片
tmp_Image.ImageUrl = "~/images/Shell32 019.ico";
}
else
{
networkFlag = false;
tmp_Image.ImageUrl = "~/images/Shell32 132.ico";
}
}
}
GridView中绑定列网络通讯状态显示
最新推荐文章于 2015-12-07 14:51:58 发布