Hi
I have below code in code behind. I want when user clicks on Group Name row data should get filled in Table footer columns
C#
StudentDetail Res = bALStudents.GetStudentDetail(Convert.ToInt32(colum.StudentID));
lblGroup.Text = colum.Group.GroupName;
htmlTable.Append("");
htmlTable.Append("" + colum.ID + "");
htmlTable.Append("" + Count.ToString() + "");
htmlTable.Append("" + colum.Group.GroupName + "");
htmlTable.Append("" + Res.Name + "");
htmlTable.Append("" + "" + "");
htmlTable.Append("" + "" + "");Code
-
Select Student
AddThanks

Naimish MakwanaRank #324 · 7.7K reputationPosted Apr 16, 2023, 12:32 AM EDT
Based on the provided code, it looks like you are creating a dynamic HTML table with student details and a footer row containing form controls to add new records.
To fill the footer columns with data when a user clicks on a group name row, you can add a JavaScript function that will handle the click event and populate the form controls with the selected group's data.
Here's an example of how you can achieve this:
1. Add an "onclick" attribute to the group name cell in the table row:
htmlTable.Append("" + colum.Group.GroupName + "");2. Define the "fillFooterColumns" function in a script tag within the HTML file:
function fillFooterColumns(cell) { // Get the table footer row var footerRow = document.getElementById("AddCtrls").rows[0]; // Get the group name from the clicked cell var groupName = cell.innerHTML; // Set the group name in the footer label var lblGroup = footerRow.cells[1].getElementsByTagName("label")[0]; lblGroup.innerHTML = groupName; // Populate the dropdown list with the students in the selected group var ddlStudent = footerRow.cells[2].getElementsByTagName("select")[0]; ddlStudent.options.length = 1; // Clear existing options var groupStudents = /* TODO: get students in the selected group using AJAX or a postback */; for (var i = 0; i3. Update the server-side "lnkAddRecord_Click" event handler to retrieve the selected values from the footer controls and add a new record to the database.
Note: You will need to implement the TODO comment in step 2 to retrieve the students in the selected group using AJAX or a postback.
Thanks
Naimish Makwana