本文介绍了gridview复选框将选定的行添加到另一个页面中的另一个网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
选中选中的行或到另一页中另一个girdview的行,如果有的话,请将代码发送给我
第1页
checkbox selected row or rows to another girdview in another page please send me the code if you have it
page 1
<table>
<tr>
<td>
<table>
<tr>
<td>
<table>
<tr>
<td>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3"
GridLines="None" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px"
CellSpacing="1"
AutoGenerateSelectButton="false" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<input type ="checkbox" value="" onclick='addthis(this,<%#Eval("EmpSalary") %>)' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<%# Eval("EmpName") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Emp Salary">
<ItemTemplate>
<%# Eval("EmpSalary") %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<RowStyle BackColor="#DEDFDE" ForeColor="Black" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
</asp:GridView>
<input type="text" id="resdiv" value="0" />
<asp:HiddenField ID="hidden1" runat="server" />
<asp:Button ID="bbbtbn" runat="server" Width="50px" onclick="bbbtbn_Click" />
<input type="text" id="txtxt" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
第2页
page 2
<table>
<tr>
<td>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3"
GridLines="None" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px"
CellSpacing="1"
AutoGenerateSelectButton="false" >
<Columns>
</Columns>
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<RowStyle BackColor="#DEDFDE" ForeColor="Black" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
</asp:GridView>
</td>
</tr>
</table>
推荐答案
foreach(Gridviewrow gvr in Gridview1.Rows)
{
if(((CheckBox)gvr.findcontrol("CheckBox1")).Checked == true)
{
int uPrimaryid= gvr.cells["uPrimaryID"];
}
}
您将获得基本ID
调用selectdata(uPrimaryid)它将返回数据集
session ["ds"] = selectdata(uPrimaryid)或
将其添加到querystring ... aspx?id = uPrimaryid
重定向到另一页
获取querstring request.querstring("id")
调用方法selectdata(uPrimaryid)
使用gridview.databind()进行绑定
you will get primaryid
call selectdata(uPrimaryid) it will return data set
session["ds"]=selectdata(uPrimaryid) or
add it in querystring ...aspx?id=uPrimaryid
redirect to another page
get querstring request.querstring("id")
call method selectdata(uPrimaryid)
bind using gridview.databind();
这篇关于gridview复选框将选定的行添加到另一个页面中的另一个网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!