我有一个按钮,onClick
事件,我想将数据从 Oracle DB 加载GridView
到ModalPopupExtender
.
问题是 Modalpopup 正在显示,但 gridView 中没有数据加载。
谁能指导我在哪里做错了。
ASP 代码
<asp:Label ID="dummyLabel" runat="server" />
<ajax:ModalPopupExtender ID="mpeServiceType" runat="server" TargetControlID="dummyLabel" CancelControlID="BtnCloseServiceTypeMPE" Drag="true" PopupControlID="pnlServiceType" Enabled="True" >
</ajax:ModalPopupExtender>
<asp:Button runat="server" ID="btnSelectServiceType" Text="Select Srv Type" OnClick="btnSelectServiceType_Click" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Button ID="Button2" Style="display: none" runat="server" Width="120" Text="Filter Charges" ToolTip="show Chargefilter-Dialog" />
<asp:Button ClientIDMode="Static" ID="BtnCloseServiceTypeMPE" Text="Close" ToolTip="close filter-dialog" CausesValidation="false" Width="150px" runat="server" /><br />
<table border="1">
<tr>
<td dir="rtl">
<asp:GridView ID="gvServiceType" runat="server"
CssClass="mGrid" AlternatingRowStyle-CssClass="alt" DataKeyNames="APP_ID,SRV_TYPE"
AutoGenerateColumns="False" OnSelectedIndexChanged="gvServiceType_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="APP_ID" HeaderText=(APP_ID)" ReadOnly="True" SortExpression="APP_ID" />
<asp:BoundField DataField="SRV_TYPE" HeaderText="SRV_TYPE)" SortExpression="SRV_TYPE" ReadOnly="True" />
<asp:BoundField DataField="SRV_NAME" HeaderText="SRV_NAME)" SortExpression="SRV_NAME" />
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:Button ID="btnSelect" runat="server" CommandName="Select" Text="Select" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
C# 代码
protected void btnSelectServiceType_Click(object sender, EventArgs e)
{
string strSQLconnection = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.0.24)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=PROD)));User Id=aaziz;Password=32145;";
OracleConnection conn = new OracleConnection(strSQLconnection);
OracleCommand sqlCommand = new OracleCommand("select * from INCOME.srv_types where APP_ID='3' AND SRV_TYPE='8'", conn);
conn.Open();
OracleDataReader reader = sqlCommand.ExecuteReader();
gvServiceType.DataSource = reader;
gvServiceType.DataBind();
mpeServiceType.Show();
}