PDA

View Full Version : [CLOSED] Why is SelectedRecordID empty?



osef
Dec 23, 2013, 8:28 PM
<ext:ResourceManager ID="ResourceManager1" runat="server" />

<ext:GridPanel
ID="gpAlimentos"
runat="server"
Height="300"
Width="802"
Title="Alimentos">
<TopBar>
<ext:Toolbar ID="tbTopAlimentos" runat="server">
<Items>
<ext:Button ID="btnGuardar" runat="server" Text="Save">
<DirectEvents>
<Click OnEvent="btnGuardar_Click" Delay="1">
</Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Store>
<ext:Store ID="sAlimentos" runat="server">
<Model>
<ext:Model ID="mAlimentos" runat="server" IDProperty="ID">
<Fields>
<ext:ModelField Name="ID" Type="Int" />
<ext:ModelField Name="Grupo" Type="String" />
<ext:ModelField Name="Nombre" Type="String" />
<ext:ModelField Name="Marca" Type="String" />
<ext:ModelField Name="Cantidad" Type="Int" />
<ext:ModelField Name="UnidadMedida" Type="String" />
<ext:ModelField Name="Precio" Type="Float" />
<ext:ModelField Name="Lugar" Type="String" />
<ext:ModelField Name="Campo" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:NumberColumn ID="ncID" runat="server" DataIndex="ID" Text="ID" />
<ext:Column ID="cGrupo" runat="server" DataIndex="Grupo" Text="Grupo" />
<ext:Column ID="cNombre" runat="server" DataIndex="Nombre" Text="Nombre" />
<ext:Column ID="cMarca" runat="server" DataIndex="Marca" Text="Marca" />
<ext:NumberColumn ID="ncCantidad" runat="server" DataIndex="Cantidad" Text="Cantidad" />
<ext:Column ID="cUnidadMedida" runat="server" DataIndex="UnidadMedida" Text="Unidad de medida" />
<ext:NumberColumn ID="ncPrecio" runat="server" DataIndex="Precio" Text="Precio" />
<ext:Column ID="cLugar" runat="server" DataIndex="Lugar" Text="Lugar" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="rsmAlimentos" runat="server" Mode="Single">
</ext:RowSelectionModel>
</SelectionModel>
</ext:GridPanel>




protected void Page_Load(object sender, EventArgs e)
{
List<Alimentos> list = new List<Alimentos>(5);

for (int i = 1; i <= 5; i++)
{
Alimentos alimentos = new Alimentos
{
ID = i,
Grupo = ("Grupo" + i),
Nombre = ("Nombre" + i),
Marca = ("Marca" + i),
Cantidad = i,
UnidadMedida = ("UnidadMedida" + i),
Precio = Convert.ToDecimal(i * 85.12),
Lugar = ("Lugar" + i),
Campo = ("Campo" + i)
};

list.Add(alimentos);
}

sAlimentos.DataSource = list;
sAlimentos.DataBind();
}

public class Alimentos
{
public int ID { get; set; }
public string Grupo { get; set; }
public string Nombre { get; set; }
public string Marca { get; set; }
public int Cantidad { get; set; }
public string UnidadMedida { get; set; }
public decimal Precio { get; set; }
public string Lugar { get; set; }
public string Campo { get; set; }
}

protected void btnGuardar_Click(object sender, DirectEventArgs e)
{
string strRow = rsmAlimentos.SelectedRecordID;
X.Msg.Alert("Record", strRow).Show();
}


7398

Zdenek
Dec 23, 2013, 9:12 PM
Hello
I tried your sample and it works for me (Ext.Net 2.4.0.30091)

Hovewer I would recommend to modify the code of Page_Load


protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
// what you have now
}
}

if you still have problems, , can you take firebug or fiddler and check that part if request is something like (third line is important)


__EVENTARGUMENT btnGuardar|event|Click
__EVENTTARGET ResourceManager1
rsmAlimentos [{"RecordID":3,"RowIndex":2}


Regards
Zdenek

osef
Dec 24, 2013, 3:46 AM
Hello
I tried your sample and it works for me (Ext.Net 2.4.0.30091)

Hovewer I would recommend to modify the code of Page_Load


protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
// what you have now
}
}

if you still have problems, , can you take firebug or fiddler and check that part if request is something like (third line is important)


__EVENTARGUMENT btnGuardar|event|Click
__EVENTTARGET ResourceManager1
rsmAlimentos [{"RecordID":3,"RowIndex":2}


Regards
Zdenek

This is working, thank you.