您的位置:首页 > 理论基础 > 计算机网络

GridView中绑定列网络通讯状态显示

2015-03-04 15:03 141 查看
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";
}

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐