日期:2014-05-16 浏览次数:21016 次
一:JQuery实现在GridView中 点击一行的任意位置 选中这一行中的CheckBox
$(function(){
        $("#GridView1").find("tr").click(function(){
            $(this).find("input[type='checkbox']").attr("checked",!$(this).find("input[type='checkbox']").attr("checked"));
             
        });
         
    })
protected void gvProjectList_RowDataBound(object sender, GridViewRowEventArgs e) {//这是鼠标移到某行时改变某行的背景 e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#eaeaea';");//鼠标移走时恢复 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;"); }
前台实现:
 <ItemTemplate>
          <asp:LinkButton ID="LinkDelete" runat="server" Visible ="false" OnClientClick="if(!confirm('确定要删除这条纪录吗?')) return false;"
                       CommandName="lb_delete" Text="删除" CommandArgument='<%#Bind("aa") %>' />
  </ItemTemplate>
//数据绑定时对删除按钮添加提示
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
	//只有数据行才有绑定数据
	if (e.Row.RowType == DataControlRowType.DataRow)
        {
	//由于是链接按钮所以声明一个链接按钮,根据实际情况变动
            LinkButton lnkBtFalg = e.Row.Cells[0].Controls[0] as LinkButton;
            lnkBtFalg.Attributes.Add("onclick", "javascrip:return confirm('您真要的删除吗!')");
        }
    }
public static void ShowMessage(System.Web.UI.Page thePage,string Text)
        {
            Text = Text.Replace("\"", "").Replace("'", "").Replace("\r", "").Replace("\n", "");
            thePage.ClientScript.RegisterStartupScript(thePage.GetType(), Guid.NewGuid().ToString(),
              "alert('"+Text+"');", true);}
 public static string Md5Hash(string text)
        {
            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(text);
            MD5 md5 = MD5.Create();
            byte[] resultBytes=md5.ComputeHash(bytes);//md5
            string md5Result = "";
            for (int i = 0; i < resultBytes.Length; i++)
            {
                md5Result += resultBytes[i].ToString("X2");
            }
            return md5Result;
        }