次のように、SQLサーバーに2つのテーブルがあります
PatientDetail - 1st table name
PatientId --- primary key
firstname
lastname
Patexam - 2nd table name
PId ---- foreign key of first table PatientId
Exam
以下のように、最初のテーブルのすべての列を表示するページに1つのグリッドビューがあります
<asp:GridView ID="gvDoctorList" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<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>
テキスト値 = "formatric3d" のボタンが 1 つあり、グリッドビューで 1 つの行を選択してからボタンをクリックすると、
value = "formatric3d",
patientid
そのため、クリックイベントで、選択した行とbutton text value = "formatric3d"
テーブル名 Patexamに挿入したいと考えています。
これは、gridviewPatientId
で選択されている PId が に等しく、試験が に等しいことを意味しbutton text value = "formatric3d"
ます。