次のGridview(動作します)と「EmptyDataText」タグがあり、送信ボタンをクリックした後にデータベースからデータが見つからなかった場合に画面にメッセージを表示する必要があります。問題は、ページを開いた瞬間に「データが見つかりません」というメッセージがページに表示されることですが、ユーザーがデータベースに見つからなかったメールアドレスを入力した場合にのみメッセージを表示したいのです。私はそれを正しく説明したことを願っています、私は本当にこの問題をより良い方法で言うことはできません、お願いします!
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
DataSourceID="SqlDataSource" EmptyDataText="The data could not be found" CellSpacing="3" CellPadding="4"
GridLines="None" ForeColor="#333333">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
SortExpression="ID">
<ItemStyle Font-Names="Verdana" Font-Size="9pt" />
<HeaderStyle Font-Names="Verdana" Font-Size="10pt" />
</asp:BoundField>
<asp:BoundField DataField="name" HeaderText="Name" SortExpression="name">
<ItemStyle Font-Names="Verdana" Font-Size="9pt" />
<HeaderStyle Font-Names="Verdana" Font-Size="10pt" />
</asp:BoundField>
<asp:BoundField DataField="EmailAddress" HeaderText="Email Address" SortExpression="EmailAddress">
<ItemStyle Font-Names="Verdana" Font-Size="9pt" />
<HeaderStyle Font-Names="Verdana" Font-Size="10pt" />
</asp:BoundField>
<asp:BoundField DataField="Address1" HeaderText="Address1" SortExpression="Address1">
<ItemStyle Font-Names="Verdana" Font-Size="9pt" />
<HeaderStyle Font-Names="Verdana" Font-Size="10pt" />
</asp:BoundField>
<asp:BoundField DataField="Address2" HeaderText="Address2" SortExpression="Address2">
<ItemStyle Font-Names="Verdana" Font-Size="9pt" />
<HeaderStyle Font-Names="Verdana" Font-Size="10pt" />
</asp:BoundField>
<asp:BoundField DataField="city" HeaderText="City" SortExpression="city">
<ItemStyle Font-Names="Verdana" Font-Size="9pt" />
<HeaderStyle Font-Names="Verdana" Font-Size="10pt" />
</asp:BoundField>
<asp:BoundField DataField="PostCode" HeaderText="Post Code" SortExpression="PostCode">
<ItemStyle Font-Names="Verdana" Font-Size="9pt" />
<HeaderStyle Font-Names="Verdana" Font-Size="10pt" />
</asp:BoundField>
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EditRowStyle BackColor="#999999" />
</asp:GridView>
これは非常に単純なことかもしれませんが、ページの更新方法と関係があるのでしょうか。または、それは非常に難しいかもしれません...ユーザーが情報を入力した後でも、メッセージが画面に表示されることを本当に望んでいません。
ありがとう。
ページのデフォルトの左側にあるのではなく、EmptyDataText = "no info"タグを(グリッドビューで)中央に配置したいと思います。