列表中每行有多个下拉框,在后台databound中调用前台的脚本函数,传行索引,前台接收索引获取指定行的特定下拉框,并取值,代码如下:
后台:
protected void lpgProductList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) {
<pre class="html" name="code"> int index = e.Row.RowIndex;
<pre class="html" name="code"> ImageButton imgViewProduct = (ImageButton)e.Row.FindControl("lbtnViewProduct"); ImageButton imgEditProduct = (ImageButton)e.Row.FindControl("lbtnEditProduct");
imgViewProduct.Attributes.Add("onclick", string.Format("ViewItemProductAllParam('{0}','{1}','{2}'); return false;", productID, 1, index));
前台脚本:
//查看、编辑成品信息 function ViewItemProduct(sProductEntityID, actionType, index) { var indexid=1*index+2; var ddlid = "ctl08_ProductList1_lpgProductList_ctl" + indexid + "_ddlTextType" var texttype = document.getElementById(ddlid).value;
.....
}