将GridView里面选中的主键作为参数传递另外一个页面的办法?
将GridView里面选中的主键作为参数传递另外一个页面的办法?
这个用post怎么实现?
A页面代码:
<script language="javascript" type="text/javascript">
function SelectAll() {
var cbList = document.getElementsByTagName("input");
for (var i = 0; i < cbList.length; i++) {
if (cbList[i].type == "checkbox") {
cbList[i].checked = true;
}
}
}
function Post() {
document.forms[0].submit();
}
</script>
<form id="form1" runat="server" method="post" action="B.aspx">
<div>
<input id="BTN_POST" type="button" value="button" onclick="Post();" />
<br />
<input id="CB_SELECT_ALL" type="checkbox" onclick="SelectAll();" />全选<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
DataKeyNames="DIC_ID">
<Columns>
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<asp:CheckBox ID="CB_SELECT" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="DIC_ID" HeaderText="DIC_ID" SortExpression="DIC_ID" />
<asp:BoundField DataField="DIC_CODE" HeaderText="DIC_CODE" SortExpression="DIC_CODE" />
<asp:BoundField DataField="DIC_NAME" HeaderText="DIC_NAME" SortExpression="DIC_NAME" />
<asp:BoundField DataField="PARENT_CODE" HeaderText="PARENT_CODE" SortExpression="PARENT_CODE" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:JYJYConnectionString %>"
SelectCommand="SELECT [DIC_ID], [DIC_CODE], [DIC_NAME], [PARENT_CODE],FROM [DICTIONARY_INFO] ORDER BY [DIC_ID]">
</asp:SqlDataSource>
</div>
</form>
B页面接收:
protected void Page_Load(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
if(!IsPostBack)
{
if (Request["DIC_ID"] != null)
{
sb.Append(Request["DIC_ID"]);
}
Response.Write(sb.ToString());
}
}
但是B页面接收不到值
请问一下哪里有误?
请高手指点
------解决方案--------------------Request["DIC_ID"] 名字不对,
------解决方案--------------------沒看到在A頁面有傳入參數到B
------解决方案--------------------A页面后台事件呢
------解决方案--------------------
HTML code
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="newsID,Us_ID"
DataSourceID=&quo