Hi JennyD6856,
Check this example. Now please take its reference and correct your code.
HTML
<div>
<table class="table table-striped table-bordered table-condensed">
<tr>
<td>
<asp:Panel ID="Panel1" runat="server" ScrollBars="Vertical">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<table class="table table-striped table-bordered table-condensed">
<tr>
<td>
Service Name:
</td>
<td>
<asp:Label ID="lblservicename" CssClass="viewlabel" runat="server" Text='<%# Eval("ServiceName") %>'></asp:Label>
</td>
<td rowspan="5">
<asp:Button ID="btnServe" runat="server" Text="Serve" OnClick="btnServe_Click" />
</td>
</tr>
<tr>
<td>
Service Date:
</td>
<td>
<asp:Label ID="lblservicedate" CssClass="viewlabel" runat="server" Text='<%# Eval("StartDate") %>'></asp:Label>
</td>
</tr>
<tr>
<td>
Status:
</td>
<td>
<asp:Label ID="lblStatus" CssClass="viewlabel" runat="server" Text="Pending"></asp:Label>
</td>
</tr>
<tr>
<td>
Technician:
</td>
<td>
<asp:Label ID="lblTechnician" CssClass="viewlabel" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
Comment:
</td>
<td>
<asp:Label ID="lblComment" CssClass="viewlabel" runat="server"></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</asp:Panel>
</td>
<td>
<asp:Panel ID="Panel2" runat="server">
<table>
<tr>
<td>
Technician:
</td>
<td>
<asp:DropDownList ID="ddltech" runat="server">
<asp:ListItem Text="Select" Value="Select" />
<asp:ListItem Text="Technician 1" Value="Technician 1" />
<asp:ListItem Text="Technician 2" Value="Technician 2" />
<asp:ListItem Text="Technician 3" Value="Technician 3" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Comment:
</td>
<td>
<asp:TextBox ID="txtcomment" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="bok" runat="server" Text="Ok" OnClick="bok_Click" />
</td>
</tr>
</table>
</asp:Panel>
</td>
</tr>
</table>
</div>
Code
C#
static int index = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.AddRange(new System.Data.DataColumn[3] {
new System.Data.DataColumn("Id", typeof(int)),
new System.Data.DataColumn("ServiceName", typeof(string)),
new System.Data.DataColumn("StartDate",typeof(DateTime)) });
dt.Rows.Add(1, "Service Name 1", "05/01/2018");
dt.Rows.Add(2, "Service Name 2", "05/02/2018");
dt.Rows.Add(3, "Service Name 3", "05/03/2018");
dt.Rows.Add(4, "Service Name 4", "05/04/2018");
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
}
protected void bok_Click(object sender, EventArgs e)
{
string technician = ddltech.SelectedValue.ToString();
string comment = txtcomment.Text;
(Repeater1.Items[index].FindControl("lblTechnician") as Label).Text = technician;
(Repeater1.Items[index].FindControl("lblComment") as Label).Text = comment;
}
protected void btnServe_Click(object sender, EventArgs e)
{
Panel2.Visible = true;
RepeaterItem item = (sender as Button).NamingContainer as RepeaterItem;
index = item.ItemIndex;
}
VB.Net
Shared index As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt As System.Data.DataTable = New System.Data.DataTable()
dt.Columns.AddRange(New System.Data.DataColumn(2) {New System.Data.DataColumn("Id", GetType(Integer)), New System.Data.DataColumn("ServiceName", GetType(String)), New System.Data.DataColumn("StartDate", GetType(DateTime))})
dt.Rows.Add(1, "Service Name 1", "05/01/2018")
dt.Rows.Add(2, "Service Name 2", "05/02/2018")
dt.Rows.Add(3, "Service Name 3", "05/03/2018")
dt.Rows.Add(4, "Service Name 4", "05/04/2018")
Repeater1.DataSource = dt
Repeater1.DataBind()
End If
End Sub
Protected Sub bok_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim technician As String = ddltech.SelectedValue.ToString()
Dim comment As String = txtcomment.Text
CType(Repeater1.Items(index).FindControl("lblTechnician"), Label).Text = technician
CType(Repeater1.Items(index).FindControl("lblComment"), Label).Text = comment
End Sub
Protected Sub btnServe_Click(ByVal sender As Object, ByVal e As EventArgs)
Panel2.Visible = True
Dim item As RepeaterItem = TryCast((TryCast(sender, Button)).NamingContainer, RepeaterItem)
index = item.ItemIndex
End Sub
Screenshot