PDA

View Full Version : [CLOSED] Rowselection in Codebehind returns 0 items



blueworld
Aug 22, 2013, 2:26 PM
Hi

please see my democode. There is a checkSelection Button that returns the number of selected rows.
It is always 0.
In the debug mode I can see that sm.SelectedRows has 0 items.

I am wondering why it does not work





<%@ Page Language="VB" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
<title></title>

<script runat="server">
Private Class TestObject
Public Property ID As Integer
Public Property Name As String
Public Property IsValid As Boolean
End Class

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not ExtNet.IsAjaxRequest Then
Dim xx As New Generic.List(Of TestObject)
For counter = 0 To 30
Dim testObject As New TestObject
testObject.ID = counter
testObject.Name = "Name" + counter.ToString()
If counter Mod 2 Then
testObject.IsValid = False
Else
testObject.IsValid = True
End If
xx.Add(testObject)
Next

FahrzeugeStore.DataSource = xx
FahrzeugeStore.DataBind()

End If
End Sub



<DirectMethod()>
Public Sub checkSelection()
Dim sm As RowSelectionModel = TryCast(Me.FahrzeugeGrid.GetSelectionModel(), RowSelectionModel)
Dim ids As New Generic.List(Of String)
Dim counter As Integer = 0

For Each row As SelectedRow In sm.SelectedRows
ids.Add(row.RecordID)
counter = counter + 1
Next

Notification.Show(New NotificationConfig() With { _
.Icon = Icon.Information, _
.Height = 80, _
.HideDelay = 3000, _
.AlignCfg = New NotificationAlignConfig() With { _
.ElementAnchor = AnchorPoint.BottomRight, _
.TargetAnchor = AnchorPoint.BottomRight, _
.OffsetX = 0, _
.OffsetY = 0 _
}, _
.ShowFx = New SlideIn() With { _
.Anchor = AnchorPoint.BottomRight, _
.Options = New FxConfig() With { _
.Easing = Easing.BounceOut _
} _
}, _
.HideFx = New SwitchOff(), _
.Html = "You have selected " + counter.ToString + " rows" _
})

End Sub
</script>

<script>


</script>

<style>

</style>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />

<ext:Viewport ID="Viewport1" runat="server" Layout="borderLayout">
<Items>
<ext:Panel ID="Panel1" runat="server" Region="Center" Layout="FitLayout">
<TopBar>
<ext:Toolbar runat="server" ID="Toolbar1">
<Items>
<ext:Button runat="server" ID="Button1" Text="Check Selected Rows">
<Listeners>
<Click Handler="App.direct.checkSelection();" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Items>
<ext:GridPanel ID="FahrzeugeGrid" runat="server" Title="Fahrzeugauswahl"
Icon="Lorry" Flex="3" ForceFit="true" SelectionMemory="false">
<View>
<ext:GridView ID="Gridview1" runat="server" StripeRows="true"></ext:GridView>
</View>
<Store>
<ext:Store ID="FahrzeugeStore" runat="server">
<Model>
<ext:Model ID="Model1" runat="server" IDProperty="ID">
<Fields>
<ext:ModelField Name="ID" />
<ext:ModelField Name="Name" />
<ext:ModelField Name="IsValid" />
</Fields>
</ext:Model>
</Model>
<Listeners>

</Listeners>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ID="Column1" runat="server" Text="ID" DataIndex="ID"
Sortable="True" Flex="1" Visible="false" />

<ext:Column ID="Column2" runat="server" Text="Name" DataIndex="Name"
Sortable="True" Flex="1" />

</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel Mode="Multi" runat="server" />
</SelectionModel>
</ext:GridPanel>

</Items>
</ext:Panel>



</Items>
</ext:Viewport>
</body>
</html>

Vladimir
Aug 22, 2013, 3:14 PM
You have no ASP.NET form therefore there is no automatic submit

blueworld
Aug 22, 2013, 3:17 PM
You have no ASP.NET form therefore there is no automatic submit

Thank you Vladimir