我在sql server中有两个表如下
PatientDetail - 1st table name
PatientId --- primary key
firstname
lastname
Patexam - 2nd table name
PId ---- foreign key of first table PatientId
Exam
我在页面中有一个gridview,它显示了第一个表的所有列,如下所示
<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" 现在,当我在 gridview 中选择一行然后单击按钮时
value = "formatric3d",
所以点击事件我想插入选定的行patientid
以及button text value = "formatric3d"
表名Patexam。
这意味着PatientId
在 gridview 和 Exam 上选择的PId 等于button text value = "formatric3d"
。