How do I pass the ID value linked to a repeater row to open the values in a new webform with textfields which can then be edited and updated in repeater (SQL Stored procedure). I am new to repeaters and I managed to do this using a GridView but I'm not sure how to do it with a repeater.
What I did with the GridView c# which worked perfect in Default.aspx.cs:
if (dgvEmployees.SelectedIndex != -1)
{
indexId = dgvEmployees.SelectedRow.Cells[1].Text;
Response.Redirect("About.aspx?&Id=" + indexId);
}
What is received in About.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if(!String.IsNullOrEmpty(Request.QueryString["Id"]))
{
idNum = Convert.ToInt32(Request.QueryString["Id"]);
if(!IsPostBack)
{
FillEmployeeData();
}
}
}
This is the repeater code:
<asp:Repeater ID="rptList" runat="server" OnItemDataBound="rptList_ItemDataBound" Visible="true">
<HeaderTemplate>
<table class="table table-bordered" id="VersionsTable">
<tr>
<th>Actions
</th>
<th>Employee Number
</th>
<th>ID Number
</th>
<th>Employee Name
</th>
<th>Employee Surname
</th>
<th>Number of Dependants
</th>
<th>Race
</th>
<th>Gender
</th>
<th>Delete
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tbody>
<tr style="cursor:pointer" onmouseover="style.backgroundColor='#E6E6E6'" onmouseout="style.backgroundColor=''" onclick="style.backgroundColor='#727A91'">
<asp:HiddenField ID="hIDfield" runat="server" Value='<%#Eval("Id")%>' />
<td>
<asp:button runat="server" OnClick="btnEdit_Click" CssClass="btn btn-default" Text="Edit"/>
</td>
<td onclick="PopupEdit('<%# Eval("EmployeeNumber") %>')">
<%# Eval("EmployeeNumber") %>
</td>
<td>
<%# Eval("IDNumber") %>
</td>
<td>
<%# Eval("employeeName") %>
</td>
<td>
<%# Eval("employeeSurname") %>
</td>
<td>
<%# Eval("numberOfDependants") %>
</td>
<td>
<%# Eval("RaceId") %>
</td>
<td>
<%# Eval("GenderId") %>
</td>
<td style="text-align:center">
<asp:CheckBox ID="chkDelete" CssClass="form-control" runat="server" />
</td>
</tr>
</tbody>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Thank you for your help!