Anas Mouki

Anas Mouki

  • NA
  • 9
  • 465

how to get an item from a data source within a repeater

Oct 5 2018 9:38 AM
i have a list of items within a repeater and im trying to get the index of each item after clicking a button and inserting the data into another table.i tried almost everything but cant find how to make it possible. the code below is the one i used to retrieve the data from the db and display it on the repeater :
 
 
protected void Page_Load(object sender, EventArgs e)
     {   
        con.Open();  
        SqlCommand cmd = con.CreateCommand();
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "select caract, image_Ter, taille, info from Terrain";
        cmd.ExecuteNonQuery();
        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(dt);
        temp.DataSource = dt;
        temp.DataBind();
        con.Close();
      }
and heres the button that i want it to get the index and insert the data into another table :
<asp:Button class="btn btn-secondary btn-xl" data-dismiss="modal"      runat="server" ID="choice" Text="Add" />


Answers (2)