今天研究了一下新浪和CSND的博客,觉得新浪的做得更细致,跟人性化,CSDN的有点杂乱。 private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { //添加编号 if(e.Item.ItemIndex!=-1) { Label Label1; Label1=(Label)e.Item.FindControl("userName"); ImageButton ImageButton1; ImageButton1=(ImageButton)e.Item.FindControl("view_Bt"); string userPhotoHttpPath = System.Configuration.ConfigurationSettings.AppSettings["adminSite"]+"/userAdmin/userPhoto"; userPhotoHttpPath=userPhotoHttpPath+"/thumbnail/"+Label1.Text.Trim()+".jpg"; myFunctionNew fun=new myFunctionNew(); if(fun.UrlExistsUsingHttpWebRequest(userPhotoHttpPath)) { ImageButton1.ImageUrl=userPhotoHttpPath; } else { ImageButton1.ImageUrl="images/view.gif"; } fun.Dispose(); } }