我在asp.net页面中有以下内容:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="DateToVisit"
DataSourceID="AccessYouthSchedule" AutoGenerateEditButton="True">
<Columns>
<asp:BoundField DataField="Observer" HeaderText="Observer" SortExpression="Observer" />
<asp:BoundField DataField="DateToVisit" HeaderText="DateToVisit" ReadOnly="True" SortExpression="DateToVisit" />
<asp:BoundField DataField="YouthClass" HeaderText="YouthClass" SortExpression="YouthClass" />
<asp:BoundField DataField="DidVisitOccur" HeaderText="DidVisitOccur" SortExpression="DidVisitOccur" />
<asp:BoundField DataField="IdForEmail" HeaderText="IdForEmail" SortExpression="IdForEmail" />
<asp:CheckBoxField DataField="WeekBeforeNoticeSent" HeaderText="WeekBeforeNoticeSent" SortExpression="WeekBeforeNoticeSent" />
<asp:CheckBoxField DataField="DayOfNoticeSent" HeaderText="DayOfNoticeSent" SortExpression="DayOfNoticeSent" />
<asp:BoundField DataField="PlanToVisit" HeaderText="PlanToVisit" SortExpression="PlanToVisit" />
</Columns>
</asp:GridView>
<asp:AccessDataSource ID="AccessYouthSchedule" runat="server" DataFile="~/App_Data/SundaySchool.mdb"
SelectCommand="SELECT Observer, [DateToVisit], [YouthClass], [DidVisitOccur], [IdForEmail], [WeekBeforeNoticeSent], [DayOfNoticeSent], [PlanToVisit] FROM [YouthSchedule]"
UpdateCommand="UPDATE YouthSchedule SET Observer = @Observer, YouthClass = @YouthClass, DidiVisitOccur = @DidVisitOccur, IdForEmail = @IdForEmail,
WeekBeforeNoticeSent = @WeekBeforeNoticeSent, DayOfNoticeSent = @DayOfNoticeSent, PlanToVisit = @PlanToVisit WHERE DateToVisit = @DateToVisit">
</asp:AccessDataSource>
这很有效。但是,我还有其他asp:我想使用的AccessDataSource:
<asp:AccessDataSource ID="AccessDoctrineEssentials" runat="server" DataFile="~/App_Data/SundaySchool.mdb"
SelectCommand="SELECT [DoctrineObserver1], [DoctrineObserver2], [EssentialsObserver], [DateToVisit] FROM [DoctrineAndEssentials]"
UpdateCommand="UPDATE DoctrineAndEssentials SET DoctrineObserver1 = @DoctrineObserver, DoctrineObserver2 = @DoctrineObserver2,
EssentialsObserver = @EssentialsObserver WHERE DateToVisit = @DateToVisit">
</asp:AccessDataSource>
由于这些“列”,我不能简单地设置GridView1.DataSourceId属性。有没有办法快速切换到我的其他AccessDataSource?它们主要是同一数据库中的不同表。
答案 0 :(得分:0)
这里最简单的解决方案是使用多个网格视图。