Hi
In a list i am displaying only 4-5 fields but there are more fields. How i will get the values of other fields on click of Edit button
htmlTable.Append("");
htmlTable.Append("| Sr. | Code | Description | Swift Code | Status | Action |
");
htmlTable.Append("");
foreach (DataRow row in dt.Rows)
{
String Status = "Blocked";
if (Convert.ToBoolean(row["status"]))
{
Status = "Active";
}
htmlTable.Append("");
htmlTable.Append("| " + Count.ToString() + " | ");
htmlTable.Append("" + row["bankcode"] + " | ");
htmlTable.Append("" + row["bankname"] + " | ");
htmlTable.Append("" + row["swiftcode"] + " | ");
htmlTable.Append("");
htmlTable.Append("");
//string deleteAttributes = Status == "Blocked" ? "style='pointer-events: none; opacity: 0.5;' onclick='return false;'" : "data-toggle='modal' data-target='#modal_Delete' onclick='BindData(this);'";
string deleteAttributes = Status == "Blocked" ? "style='pointer-events: none; opacity: 0.5;' onclick='return false;'" : "data-toggle='modal' data-target='#modal_Delete' ";
htmlTable.Append($"");
htmlTable.Append(" | ");
htmlTable.Append("" + row["docentry"] + " | ");
htmlTable.Append("" + row["status"] + " | ");
htmlTable.Append("
");
Count++;
}
htmlTable.Append("");
htmlTable.Append("
");
PlaceHolderTable.Controls.Add(new Literal { Text = htmlTable.ToString() });
Thanks
Aman GuptaPosted Aug 28, 2024, 4:42 PM
Hi Ramco,
To access additional fields (like docentry and status) when clicking the "Edit" button, you can store these values in data-* attributes within the HTML element. This allows you to pass all the necessary information to your JavaScript function when the user clicks the "Edit" button. Here's how you can modify your code:
Step 1: Add data-* Attributes for the Hidden Fields
You can modify the htmlTable.Append code to include data-* attributes for the hidden fields:
Step 2: Update the BindData JavaScript Function
Modify your BindData JavaScript function to retrieve the values from these data-* attributes:
Step 3: Ensure Your Modal Has the Corresponding Fields
Make sure your modal form (#modal_form_horizontal) has the appropriate fields (e.g., #txtDocEntry, #txtStatus, #txtBankCode, #txtBankName, #txtSwiftCode) where you want to populate the data:
Explanation
With this approach, you can easily pass and retrieve all necessary data when the "Edit" button is clicked, even if those fields are not directly displayed in the table.
Ramco RamcoPosted Aug 29, 2024, 1:15 AM
Hi Aman
How i will access other fields like address1,address2,city,state,pin etc . I am not displaying in the list.
Thanks