Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[ASP.NET] Problem mit Events

Empfohlene Antworten

Veröffentlicht

Hallo,

in einem Gridview liegt in einem ItemTemplate ein ImageButton. Wird die Seite das erste mal geladen, reagiert der Button erst nach 2 Klicks.

Anschließend kann ich den ImageButton in jeder Zeile ganz normal mit einem Klick benutzen.

Mit dem Button soll ein Repeater aufgerufen werden.

Dies ist der Code für das Gridview auf der aspx -Seite (Ich habe der Übersichtlichkeit wegen Formatierungselemente für Footer, Header etc. herausgenommen)


<asp:GridView ID="dg_View" runat="server" ShowFooter="True">

 <Columns>

   <asp:TemplateField>

          <ItemTemplate>

                 <asp:ImageButton ID="btnSelect" runat="server" CausesValidation="False" CommandName="Select" ImageUrl="gedachterPfad.jpg" CommandArgument='<%# CType(Container, GridViewRow).RowIndex %>' />


           </ItemTemplate>

     </asp:TemplateField>

 </Columns>

</asp:GridView>


im Codebehind wird das Event rowCommand aufgerufen
 Private Sub dg_View_RowCommand(ByVal sender As Object, _

                                       ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) _

                                       Handles dg_View.RowCommand




Try

            Select Case e.CommandName


               Case "Select"


                    Dim index As Integer = Convert.ToInt32(e.CommandArgument)

                    Dim CurrentRow As GridViewRow = dg_View.Rows(index)

                    [COLOR="Blue"]Me.LoadForCast(CType(CurrentRow.FindControl("lblProjekt"),Label).Text)[/COLOR]

               End Select

        Catch ex As Exception


        Finally


        End Try

    End Sub


Wichtig ist, dass die blau markierte Methode aufgerufen soll.

Benutze ich den Debugger, dann springt er sogar in den Methodenaufruf rein. Aber der Repeater wird trotzdem erst nach 2 Klicks angezeigt :(

Es wäre schön, wenn mir jemand einen Tipp geben könnte. Ich komm einfach net drauf an was das liegt:upps Muss ich vielleicht im Page_Load -Event den Repeater oder den ImageButton nochmal "fokusieren"?

Danke!!!

Sarene

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.