双击DataGrid后怎么取值和传值?
各位老师,我在Default.aspx页面放了个javascript:
<head runat="server">
<title></title>
<script type="text/javascript">
function SelectedIndexChanged()
{event.cancelBubble=true;
var the_obj = event.srcElement;
if(the_obj.tagName.toLowerCase() != "table" && the_obj.tagName.toLowerCase() != "tbody" && the_obj.tagName.toLowerCase() != "tr")
{cur_row = the_obj.parentElement.rowIndex;
if(cur_row!=0)
{ __doPostBack("GridView1",cur_row);
}
}
}
</script>
</head>
和一个DataGrid:
<div class="DataGrid" style="width:1261px;height:999px;margin:auto;position:relative;">
<asp:GridView onclick="javascript:SelectedIndexChanged()" ID="GridView1" runat="server" Width="1260px" Font-Size="Small" OnRowDataBound="GridView1_RowDataBound" EnableModelValidation="True" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical">
<AlternatingRowStyle BackColor="White" />
<FooterStyle BackColor="#CCCC99" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" /> <%--6B696B列标题--%>
<PagerStyle BackColor="#E6F5FA" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#E6F5FA" />
<SelectedRowStyle BackColor="#E6F5FC" ForeColor="Black" /><%-- CE5D5A第一行--%>
</asp:GridView>
</div>
然后在后台调用:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string url = "card.aspx?ID=" + e.Row.Cells[1].Text;
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F7F7DE'");//当鼠标停留时更改背景色00A9FF
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c"); //当鼠标移开时还原背景色
//e.Row.Attributes["style"] = "Cursor:hand";//设置悬浮鼠标指针形状为"小手"
// e.Row.Attributes.Add("OnDblClick", "window.open('" + url + "','', 'alwaysRaised=100,dependent=1,resizable=0,scrollbars,width=900,height=1200')");
e.Row.Attributes.Add("OnDblClick", "SelectedIndexChanged('"+e.Row.Cells[1].Text+"')");
}
}
但现在我不知道取值成功了没有,我的最终目的是把双击选中的行的每一列值赋给相应的变量,然后传递给card.aspx用,最好用 // e.Row.Attributes.Add("OnDblClick", "window.open('" + url + "','', 'alwaysRaised=100,的形式打开card.aspx
请各位老师教教我怎么做!