Lato pubblico hai questo repeater (formattazione e campi a piacere tuo, qui c'è anche una select e un checkbox):
codice:
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<div><%#Container.DataItem("articolo")%> -
<asp:TextBox ID="TextBox1" runat="server" Text=""></asp:TextBox> -
<asp:CheckBox ID="CheckBox1" runat="server" /> -
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Uomo</asp:ListItem>
<asp:ListItem>Donna</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="MyButton" runat="server" Text="Salva" />
</div>
</ItemTemplate>
</asp:Repeater>
Lato Vb questo:
codice:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
connetti()
Try
If Not IsPostBack Then
strsql = "Select * From Articoli"
cmdSql = New MySqlCommand(strsql, conn)
rs = cmdSql.ExecuteReader()
Repeater1.DataSource = rs
Repeater1.DataBind()
rs.Close()
conn.Close()
End If
Catch errore As Exception
messaggio.Text = "Si è verificato il seguente errore: " & errore.Message
Finally
conn.Close()
End Try
End Sub
Protected Sub Repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Repeater1.ItemCommand
If e.CommandName = "Salva" Then
Dim oMyPrimaryKey As Object = e.CommandArgument
Dim y = DirectCast(e.Item.FindControl("TextBox1"), TextBox).Text
Dim z = DirectCast(e.Item.FindControl("CheckBox1"), CheckBox).Checked
Dim x = DirectCast(e.Item.FindControl("DropDownList1"), DropDownList).SelectedItem.Value
messaggio.Text = oMyPrimaryKey & "-" & y & "-" & z & "-" & x
End If
End Sub
Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
DirectCast(e.Item.FindControl("MyButton"), Button).CommandArgument = e.Item.DataItem("idarticolo")
DirectCast(e.Item.FindControl("MyButton"), Button).CommandName = "Salva"
DirectCast(e.Item.FindControl("TextBox1"), TextBox).Text = e.Item.DataItem("articolo")
End Sub
Al click del button (salva) ti scrivo nella label i valori (e Id della riga)