PDA

View Full Version : [CLOSED] Get selected record data from a dataview



John_Writers
Feb 03, 2014, 8:25 AM
Hi,
I'm following an example about the dataview, but I can't figure out about how to get the selected record data server side.



<%@ Page Language="C#" AutoEventWireup="true"
Inherits="InventoryProcess_INV_AnagraphicMaster" MasterPageFile="~/DefaultNavigation.master"
Culture="auto" UICulture="auto" meta:resourcekey="PageResourcePic" MaintainScrollPositionOnPostback="true" Codebehind="INV_AnagraphicMaster.aspx.cs" %>




<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="CPH_HEAD">
<link href="Inventory.css" rel="stylesheet" />
</asp:Content>


<asp:Content ID="Cnt" runat="server" ContentPlaceHolderID="ContentTop">
<div>
<ext:Window ID="wndAccordion"
runat="server"
Title="Selezione oggetto"
BodyBorder="0"
Icon="ApplicationTileVertical"
Layout="Accordion"
Width="600">
<Items>


<ext:Panel ID="pnlPresidio" Title="Selezione Presidio" runat="server">
<Items>
<ext:DataView ID="dvPresidi" runat="server" SingleSelect="true"
AutoShow="true"
Cls="img-chooser-view"
OverItemCls="x-view-over"
ItemSelector="div.thumb-wrap">
<Store>
<ext:Store ID="stPresidi" runat="server">
<Model>
<ext:Model ID="mdlPresidi" runat="server">
<Fields>
<ext:ModelField Name="ID_INV2_LOCATION" Type="Int" />
<ext:ModelField Name="ID_INV2_LOCATION_PARENT" Type="Int" />
<ext:ModelField Name="ID_INV2_WARD" Type="Int" />
<ext:ModelField Name="WardName" Type="String" />
<ext:ModelField Name="ID_INV2_LOCATION_TYPE" Type="Int" />
<ext:ModelField Name="LocationType" Type="String" />
<ext:ModelField Name="LocationTypeImage" Type="String" />
<ext:ModelField Name="Name" Type="String" />
<ext:ModelField Name="Description" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Tpl>
<Html>
<tpl for=".">
<div class="thumb-wrap">
<div class="thumb">
<tpl if="!Ext.isIE6">
<img style="width:100px;height:100px;" src="../Images/Inventory/{LocationTypeImage}" />
</tpl>
<tpl if="Ext.isIE6">
<div style="width:100px;height:100px;filter:progid:DXImageTran sform.Microsoft.AlphaImageLoader(src="../Images/Inventory/{LocationTypeImage}")"></div>
</tpl>
</div>
<span>{Name}</span>
</div>
</tpl>
</Html>
</Tpl>
</ext:DataView>
</Items>
<BottomBar>
<ext:Toolbar runat="server" >
<Items>
<ext:ToolbarFill runat="server" />
<ext:Button runat="server" ID="btnSelezionePresidio" Text="Avanti">
<DirectEvents>
<Click OnEvent="btnSelezionePresidio_Click" />
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</BottomBar>
</ext:Panel>


<ext:Panel ID="pnlEdificioCentrale" runat="server">
<Items>




</Items>
</ext:Panel>


</Items>
</ext:Window>
</div>
</asp:Content>


Server side code, in which I need to get the selected record data..



protected void Page_Load(object sender, EventArgs e)
{
this.stPresidi.DataSource = AnagraphicMasterCore.GetPresidi(1);
}


protected void btnSelezionePresidio_Click(object sender, DirectEventArgs e)
{
int selected_ID;
foreach (SelectedRow row in dvPresidi.SelectedRows)
{
selected_ID = stPresidi.GetAt(Convert.ToInt32(row.RowIndex)).??? ???
}
}


Thanks for your help.

Have a good day.

Daniil
Feb 03, 2014, 2:03 PM
Hi @John_Writers,

Do you need all the record's fields? If so, they are not submitted automatically. Only selected records' ids and indexes are submitted automatically.

You have to send it manually, please see the "Submit selected with values" button.
http://examples2.ext.net/#/DataView/Basic/Overview/

John_Writers
Feb 03, 2014, 2:27 PM
Ok,
thank you for your time.