" />
您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> .NET >> 得得撸改名得得爱 javascript能否取得GridView中的一行值?

得得撸改名得得爱 javascript能否取得GridView中的一行值?

来源:网络整理     时间:2016/7/8 13:14:27     关键词:得得撸改名得得爱

关于网友提出的“得得撸改名得得爱 javascript能否取得GridView中的一行值?”问题疑问,本网通过在网上对“得得撸改名得得爱 javascript能否取得GridView中的一行值?”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题:得得撸改名得得爱 javascript能否取得GridView中的一行值?
描述:


 <>
                DataSourceID="ObjectDataSource1" Width="100%" CellPadding="4" ForeColor="#333333">
                
                
                
                    
                        

    
        function ShowProgressDiv() {
            var ID = $("input#idtxt").val();
            $.ajax({
                type: "GET",
                url: "GetGridViewByConditionForm.aspx",
                data: "id=" + ID,
                beforeSend: function() {
                    $("div#ProgressDiv").css("display", "block");
                },
                success: function(msg) {
                    $("div#ShowSearchResult").html(msg);
                    var html = $("div#ShowSearchResult div#div1").html();
                    $("div#ShowSearchResult").empty();
                    $("div#ShowSearchResult").html(html);
                    $("div#ShowSearchResult>div>table#gvData tr").not(":first-child").hover(function() {
                        $(this).css("cursor","pointer");
                    }, function() {
                        $(this).removeAttr("style");
                    }).click(function() {
                        var arr = new Array();
                        $(this).children("td").each(function() {
                            arr.push($(this).text());
                        });
                        alert(arr.valueOf());
                    });
                },
                complete: function() {
                    $("div#ProgressDiv").css("display", "none");
                }
            });
        }
    


 
       
       
       
 
        
        
    



 protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["id"] != null)
            {
                SqlConnection c />                 SqlCommand cmd = null;
                SqlDataAdapter adapter = null;
                try
                {
                    conn = new SqlConnection();
                    conn.ConnectionString = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
                    conn.Open();
                    cmd = new SqlCommand();
                    cmd.Connection = conn;
                    cmd.CommandType = CommandType.Text;
                    String cmdStr = "select * from dbo.Customers";
                    if (Request["id"].ToString()!=String.Empty)
                    {
                        cmdStr += " where CustomerID= '" + Request["id"].ToString() + "'";
                    }
                    cmd.CommandText = cmdStr;
                    adapter = new SqlDataAdapter(cmd);
                    DataSet ds = new DataSet();
                    adapter.Fill(ds);
                    this.gvData.DataSource = ds;
                    this.gvData.DataBind();
                }
                catch
                {
                    Response.Write("Error happend!");
                    Response.Flush();
                    Response.End();
                }
                finally
                {
                    if (adapter != null)
                    {
                        adapter.Dispose();
                    }
                    if (cmd != null)
                    {
                        cmd.Dispose();
                    }
                    if ((conn != null) && (conn.State == ConnectionState.Open))
                    {
                        conn.Close();
                    }
                }
            }
        }
解决方案3:

以下的js代码循环取GridView所有值,当然也可以取某一行的值:

    
        function getGridViewData() 
        {
            var gv = document.getElementById("<%=GridView1.ClientID%>");
            var rowStr = "";
            for (var i = 1; i < gv.rows.length-1; i++) {
                var myRow = gv.rows(i);
                for (var j = 0; j < myRow.cells.length; j++) {
                    rowStr += myRow.cells(j).innerText + "/";
                }
                alert(rowStr);
                rowStr = "";
            }
            return false;
        }
    
解决方案4:

可以的
以下作参考


function onRowCbCheck(cb,rowNewsID) {
    var obj = document.getElementById("txtNewsIds");
    if (cb.checked) {
        obj.value += rowNewsID + ",";
    }
    else {
        obj.value = obj.value.replace(","+rowNewsID + ",", ",");
    }
}



protected void gvListNews_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            String newsID = gvListNews.DataKeys[e.Row.RowIndex].Value.ToString();
            CheckBox cb = (CheckBox)e.Row.FindControl("cbRow");
            cb.Attributes.Add("onclick", "onRowCbCheck(this," + newsID + ")");
        }
    }
解决方案5:

能实现,一行的值是什么值?


以上介绍了“得得撸改名得得爱 javascript能否取得GridView中的一行值?”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2416507.html

得得撸改名得得爱相关图片

得得撸改名得得爱相关文章