单击按钮后刷新asp.net表

时间:2020-04-30 09:49:17

标签: asp.net vba vb.net visual-studio events

即使我对asp.net的了解不多,我仍在帮助他的问题。

点击事件

Protected Sub btnApprove_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnApprove.Click

    Dim x As Integer
    Dim hasChecked As Boolean = False
       For x = 0 To Me.grdDept.Rows.Count - 1
        Dim cbApprove As CheckBox
        cbApprove = CType(Me.grdDept.Rows(x).FindControl("cbApprove"), CheckBox)

        If cbApprove.Checked = True Then
            hasChecked = True
        End If
    Next

    If hasChecked = False Then
        Me.ShowConfOK("Please select a data to Approve / Finalize.", "")
    Else
        Dim obj As New BaseClasses.AccountClassAcounts
        Dim appropType_ID As String = obj.GetValue("SELECT AppropriationType_ID FROM Table_1 WHERE AppropriationSource_ID = " & Me.AppSourceID.Value, CommandType.Text)
        Me.ShowConfYesNo("Are you sure you want to approve / finalize selected Data(s)?", "approve")
      End If
    End If
End Sub

HTML

<asp:Button ID="btnApprove"  runat="server" ToolTip="Approve / Finalize Selected PAOO/s" SkinID="button" Text="Approve / Finalize" Width="172px"></asp:Button>

                                <asp:TemplateField>

                                    <ItemTemplate>

                                        <asp:CheckBox ID="cbApprove" runat="server" />

                                    </ItemTemplate>

                                </asp:TemplateField>
                                <asp:BoundField DataField="LBPF_3_Hdr_ID" HeaderText="LBPF_3_Hdr_ID" Visible="False"></asp:BoundField>
                                <asp:BoundField DataField="Office_Name" HeaderText="Department / Office / Responsibility Center">
                                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                </asp:BoundField>



                                <asp:TemplateField HeaderText="Attachment <br/> Note: Accepted file types : *.doc, *.rar, *.zip, *.xls, and *.xlsx">
                                    <HeaderStyle HorizontalAlign="Center" Width="200px"></HeaderStyle>
                                    <HeaderStyle HorizontalAlign="Center" Width="200px"></HeaderStyle>
                                    <ItemTemplate>
                                        <asp:FileUpload ID="FileUpload1" runat="server" ViewStateMode="Enabled" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>

上面的代码似乎是正常的。这里的问题是,当我在FileUpload1中选择一个文件时,它的工作正常,它在按钮的右侧显示了信息。但是在单击“批准”按钮后,它将触发上面发布的代码。没有代码可以重新加载网格或触发网格重新加载的任何代码。我不知道为什么End Sub后的表是reload or refresh,我上传的文件不见了。

注意 在Page_Load中,有一个代码,如果postback为false,它将重新加载表。但这并没有达到那部分代码。

0 个答案:

没有答案