I have a stored procedure that select data in my table.
USE [accounting2]
GO
/****** Object: StoredProcedure [dbo].[Get_Remittance] Script Date: 05/10/2017 09:32:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[Get_Remittance]
as
SELECT
ID as '#'
,COMPNAME as 'Company Name'
,[REMITTYPE] as 'Remittance Type'
,SCHEDPAY as 'Schedule Pay'
,CONVERT(varchar(10),[GEN_DATE], 101) AS 'Date Generated'
,CONVERT(varchar(10),[PAID_DATE], 101) AS 'Date Paid'
,CONVERT(varchar(10),[TRANS_DATE], 101) AS 'Date Transmitted'
,[MONTH] as 'Applicable Month'
FROM [accounting2].[dbo].[GMB_REMITTANCE]
and this is the way how i populate data in my tablE (HTML Table) during page load.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Display_RemittanceReport();
string query = "Get_Remittance";
DataTable dt = new CLS_SProd().ALLRemittance(query);
StringBuilder html = new StringBuilder();
html.Append("<table border = '1'>");
html.Append("<tr>");
html.Append("<th>");
html.Append("");
html.Append("</th>");
foreach (DataColumn column in dt.Columns)
{
html.Append("<th>");
html.Append(column.ColumnName);
html.Append("</th>");
}
html.Append("</tr>");
foreach (DataRow row in dt.Rows)
{
html.Append("<tr>");
html.Append("<td>");
//html.Append(@"<img src='Images\Pencil.ico' alt='' border=1 height=18 width=16 class='click - to - select'></img>");
html.Append("<a href='#'>Select</a>");
html.Append("</td>");
foreach (DataColumn column in dt.Columns)
{
html.Append("<td>");
html.Append(row[column.ColumnName]);
html.Append("</td>");
}
html.Append("</tr>");
}
html.Append("</table>");
PlaceHolder1.Controls.Add(new Literal { Text = html.ToString() });
Display_CompName();
}
}
Based on th code above i created a table based on my data and there will be always a link called select.
My question is how can i use that select to transfer current row in my textbox? and here is my textbox
<asp:TextBox ID="TextBox7" runat="server" OnTextChanged="TextBox7_TextChanged" ></asp:TextBox>
Updated Code
HTML
<title>GMB Monitoring System</title>
<script type="text/javascript">
$('a[actor=popup]').on('click', function () {
document.getElementById('TextBox21').value = $(this).closest('tr').find('td:eq(2)').text();
});
</script>
<%-- and so on...... --%>
C#
private void Display_Remittance()
{
//Display Remittance Report
string query = "Get_Remittance";
DataTable dt = new CLS_SProd().ALLRemittance(query);
StringBuilder html = new StringBuilder();
html.Append("<table border = '1'");
html.Append("<tr>");
html.Append("<th>");
html.Append("Select");
html.Append("</th>");
foreach (DataColumn column in dt.Columns)
{
html.Append("<th>");
html.Append(column.ColumnName);
html.Append("</th>");
}
html.Append("</tr>");
foreach (DataRow row in dt.Rows)
{
//Working Code
//html.Append("<td>");
//html.Append(@"<img src='Images\Pencil.ico' alt='' border=1 height=18 width=16 class='click - to - select'></img>");
//html.Append("<a href='#'>Select</a>");
// html.Append("<a actor='popup' href='#'>Select</a>");
//html.Append("</td>");
html.Append("<tr>");
html.Append("<td><a actor='popup' href='#'>Select</a></td>");
foreach (DataColumn column in dt.Columns)
{
html.Append("<td>");
html.Append(row[column.ColumnName]);
html.Append("</td>");
}
html.Append("</tr>");
}
html.Append("</table>");
PlaceHolder1.Controls.Add(new Literal { Text = html.ToString() });
}
TYSM