我通过编写以下代码在asp.net中创建了gridView。
<asp:GridView ID="dataGrdVwPatientDetails" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField HeaderText="Patient" />
<asp:BoundField HeaderText="Modality" />
<asp:BoundField HeaderText="Test" />
<asp:BoundField HeaderText="Time" />
<asp:BoundField HeaderText="Referring Physician" />
<asp:BoundField HeaderText="TotalRs" />
<asp:BoundField HeaderText="Concession" />
<asp:BoundField HeaderText="Paid" />
<asp:BoundField HeaderText="Pending" />
</Columns>
</asp:GridView>
现在我想在此gridView中添加空行,以便将来我可以在该单元格中添加值。
答案 0 :(得分:1)
更改您的网格视图,如下所示:
<asp:GridView ID="dataGrdVwPatientDetails" DataKeyNames="ID" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Patient" HeaderText="Patient" />
<asp:BoundField DataField="Modality" HeaderText="Modality" />
<asp:BoundField DataField="Test" HeaderText="Test" />
<asp:BoundField DataField="Time" HeaderText="Time" />
<asp:BoundField DataField="Referring_Physician" HeaderText="Referring Physician" />
<asp:BoundField DataField="TotalRs" HeaderText="TotalRs" />
<asp:BoundField DataField="Concession" HeaderText="Concession" />
<asp:BoundField DataField="Paid" HeaderText="Paid" />
<asp:BoundField DataField="Pending" HeaderText="Pending" />
</Columns>
然后您的SQL查询应如下所示:
select ID, patient, modality, test, time, Referring_Physician, TotalRs,
consession, paid, pending
from my_table
union all
select (max(ID) + 1) as ID, '' as patient, '' as modality, '' as test,
'' as time, '' as Referring_Physician, '' as TotalRs, '' as consession,
'' as paid, '' as pending
当用户更新该字符串时,您可以使用 insert 查询。