2016-03-21 27 views
1

結合我有一個是在運行時期間被填充一個的Webdata網格(每個時間在一個不同的按鈕的用戶點擊,它加載不同的信息)失去動態數據在回發

的問題是,在selected row change電網不可獲得正確的行,因爲它做了回傳,並得到網格擺脫了數據的

Protected Sub grid_load(ByVal sender As Object, ByVal e As System.EventArgs) Handles WebDataGrid1.Load 
    If Not IsPostBack Then 
     Me.WebDataGrid1.DataSource = Membership.FindUsersByName("A%") 
     Me.WebDataGrid1.DataBind() 
    End If 
End Sub 

Protected Sub WebDataGrid1_Selection_RowSelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles WebDataGrid1.RowSelectionChanged 
    Dim thisrow = e.CurrentSelectedRows 

End sub 

thisrow總是等於Nothing

我怎樣才能獲得的數據綁定()堅持在回傳這樣我可以訪問選定行中的信息?

<ig:WebDataGrid ID="WebDataGrid1" runat="server" AutoGenerateColumns="False" Width="750px" AltItemCssClass="AltRows" > 
        <Columns> 
         <ig:BoundDataField DataFieldName="UserName" DataType="System.String" Key="UserName"> 
          <Header Text="User Name"> 
          </Header> 
         </ig:BoundDataField> 
         <ig:BoundDataField DataFieldName="Email" Key="Email"> 
          <Header Text="Email"> 
          </Header> 
         </ig:BoundDataField> 
         <ig:BoundCheckBoxField DataFieldName="IsApproved" Key="IsApproved" Width="75px"> 
          <Header Text="Approved"> 
          </Header> 
         </ig:BoundCheckBoxField> 
         <ig:BoundCheckBoxField DataFieldName="IsLockedOut" Key="IsLockedOut" Width="100px"> 
          <Header Text="Locked Out"> 
          </Header> 
         </ig:BoundCheckBoxField> 
         <ig:BoundDataField DataFieldName="LastLoginDate" Key="LastLoginDate"> 
          <Header Text="LastLoginDate"> 
          </Header> 
         </ig:BoundDataField> 
        </Columns> 
        <Behaviors> 
         <ig:Selection CellClickAction="Row" CellSelectType="None" RowSelectType="Single"> 
          <SelectionClientEvents RowSelectionChanged="WebDataGrid1_Selection_RowSelectionChanged" /> 
          <AutoPostBackFlags RowSelectionChanged="True" /> 
         </ig:Selection> 
        </Behaviors> 
       </ig:WebDataGrid> 
+0

你可以在這裏發佈你的網格嗎?我的意思是aspx代碼。 –

回答

1

套裝EnableDataViewState爲true,然後WebDataGrid數據將被序列化到ViewState,並將通過持續PostBack沒有重新綁定的網格。

<ig:WebDataGrid ID="WebDataGrid1" 
       runat="server" 
       AutoGenerateColumns="False" 
       Width="750px" 
       AltItemCssClass="AltRows" 
       EnableDataViewState="True"> 
    ... 
</ig:WebDataGrid>