ASP.NET - Obtener un valor de un grupo de DataList al seleccionar

 
Vista:
sin imagen de perfil

Obtener un valor de un grupo de DataList al seleccionar

Publicado por joaquin (1 intervención) el 19/12/2016 21:14:20
Hola, buenos dias. Tengo un proyecto, y necesito ayuda. Estoy en la parte de donde muestro los datos de una tabla en DataList .

El formato del DataList tiene cabecera, muestro un campo, el cuerpo muestro un par de registro, y el pie, muestro un boton, donde tengo vinculado el ID del registro.

El tema es que usando los eventos de ItemCommand o ItemDataBound tengo el mismo problema. Recorren por todos los Datalist, y me devuelve el ultimo ID. no discrimina que boton toca

El codigo es asi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<asp:DataList ID="dlCursos" runat="server" DataSourceID="SqlDataSource2" RepeatColumns="3"
    CellSpacing="3" DataKeyField="ID"  OnItemDataBound="dlCursos_ItemDataBound"
     >
    <ItemTemplate>
        <table class="table">
            <tr>
                <th colspan="2">
                    <b>
                        <%# Eval("DESCRIPCION")%></b>
                    <asp:Label ID="LabelIDCURSO" Text='<%# Eval("id")%>' runat="server" Visible ="True" />
                </th>
            </tr>
            <tr>
                <td colspan="2">
                    <%# Eval("OBJ_GENERAL")%>
                </td>
            </tr>
            <tr>
                <td>
                    DURACION:
                </td>
                <td>
                    <%# Eval("DURACION")%>
                </td>
            </tr>
            <tr>
                <td>
                    PRECIO:
                </td>
                <td>
                    $ <%# Eval("PRECIO")%>
                </td>
            </tr>
            <tr>
                <td>
                    COMIENZA:
                </td>
                <td>
                    $ <%# Eval("FECHA_INICIO")%>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Button ID="btinfo" runat="server" Text="Más Info..." CommandName="Selecciona" />
                </td>
            </tr>
        </table>
    </ItemTemplate>
 
</asp:DataList>

Y en la parte de VB es así:
1
2
3
4
5
Protected Sub dlCursos_ItemDataBound(sender As Object, e As DataListItemEventArgs)
    Dim ValorId As Integer = DataBinder.Eval(e.Item.DataItem, "id")
    Label1.Text = ValorId
    'Server.Transfer("cur_descripcion.aspx", True)
End Sub


Estoy Usando Visual Studio 2012. Mi Proyecto es una Aplicación Web en VB
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder