gridview 找控件

protected void grv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if(e.Row.RowType==DataControlRowType.DataRow)

        {
            string id= grv.DataKeys[e.Row.RowIndex].Value.ToString();
            ImageButton img = (ImageButton)e.Row.FindControl("img");
            img.Attributes.Add("onmouseover", "showPanel(" + id + ")");
            img.Attributes.Add("onmouseout", "hidePanel(" + id + ")");
         
        }
        

    }

 

 

 

protected void grv_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        string str = ((TextBox)grv.Rows[e.RowIndex].FindControl("type")).Text.ToString();
        string id = grv.DataKeys[e.RowIndex].Value.ToString();
        bnews.updateNewsType(str, id);
        grv.EditIndex = -1;
        grvBind();
        JS.Alert(Page, "新闻类型更新成功!");
    }

你可能感兴趣的:(GridView)