다음과 같이 한 페이지에 gridview가 있습니다. Gridview에서 다른 페이지로 값 가져 오기
<asp:GridView ID="gvDoctorList" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
AllowPaging="True" AllowSorting="True" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chk" OnCheckedChanged="chk_CheckedChanged" />
<asp:Label runat="server" ID="lblPID" Visible="false" Text='<%# Eval("PatientId") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="PatientId" HeaderText="PatientId" SortExpression="PatientId" />
<asp:BoundField DataField="firstname" HeaderText="firstname" SortExpression="firstname" />
<asp:BoundField DataField="lastname" HeaderText="lastname" SortExpression="lastname" />
<asp:BoundField DataField="sex" HeaderText="sex" SortExpression="sex" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyDatabaseConnectionString %>"
SelectCommand="SELECT [PatientId],[firstname], [lastname], [sex] FROM [PatientDetails]"></asp:SqlDataSource>
지금 사용자 확인이 체크 박스 같은 시간에 나는 다른 페이지에있는 gridview에서 PatientId을 할 때 더욱 나는 SQL 테이블에 PatientId을 삽입 할. 어떤 사람이 나에게 코드 업데이트]
* :: *을 주면
많이 감사내를 Page_Load 코드는
if (!IsPostBack) {
foreach (GridViewRow row in gvDoctorList.Rows)
{
CheckBox chk = (CheckBox)row.FindControl("chk");
if (chk.Checked)
{
string patientId = ((Label)row.FindControl("lblPID")).Text;
string exam = ((Button)sender).Text;
Session[patientId] = patientId;
}
}
}
부모 변수를 세션 변수에 넣고 다른 페이지로 이동하는 동안/다른 방법으로 쿼리 문자열로 전달할 수 있습니다. – Rex
pageload에서 세션을 넣을 위치는 어디입니까? – Pratik
당신이 사용할 수있는 세션을 사용하여 귀하의 용도에 따라 – Rex