This question already has an answer here:
Calling function from generated button in Blazor [duplicate]
(1 answer)
Closed 2 years ago.
I try to create the user management in blazor.
The check box is check/uncheck when I click on it. but when It showed index out of bound. I don't know what went wrong. just try with blazor wasb. please help check this. it is just a basic component but somehow I don't get used to its usage yet.
I try to create the user management in blazor.
The check box is check/uncheck when I click on it. but when It showed index out of bound. I don't know what went wrong. just try with blazor wasb. please help check this. it is just a basic component but somehow I don't get used to its usage yet.
#page "/manageuserrole/{userId}"
#inject HttpClient client
#inject IJSRuntime js
#inject NavigationManager uriHelper
<h3>User Roles</h3>
#if (manageUserRolesDto == null)
{
<text>Loading...</text>
}
#*else if (manageUserRolesDto.Length == 0)
{
<text>No Records Found.</text>
}*#
else
{
<EditForm Model="#manageUserRolesDto" OnValidSubmit="#UpdateUserRoles">
<table class="table table-striped">
<thead>
<tr>
<th>Role</th>
<th>Status</th>
</tr>
</thead>
<tbody>
#for (int i = 0; i < manageUserRolesDto.UserRoles.Count(); i++)
{
<tr>
<td>#manageUserRolesDto.UserRoles[i].RoleName</td>
<td>
<div class="form-check m-1">
<input type="checkbox"
#bind="#manageUserRolesDto.UserRoles[i].Selected"
/>
</div>
</td>
</tr>
}
</tbody>
</table>
<button type="submit" class="btn btn-success">
Submit
</button>
</EditForm>
}
#code {
[Parameter]
public string userId { get; set; }
ManageUserRolesDto manageUserRolesDto { get; set; }
protected override async Task OnInitializedAsync()
{
manageUserRolesDto = await client.GetFromJsonAsync<ManageUserRolesDto>("api/userroles/" + userId);
}
private void checkUserRole(int i)
{
manageUserRolesDto.UserRoles[i].Selected = !manageUserRolesDto.UserRoles[i].Selected;
}
async Task UpdateUserRoles()
{
await client.PutAsJsonAsync("api/userroles/" + userId, manageUserRolesDto);
uriHelper.NavigateTo("user");
}
async Task ManagePermission(string roleId)
{
}
}
#for (int i = 0; i < manageUserRolesDto.UserRoles.Count(); i++)
{
int copy = i;
<tr>
<td>#manageUserRolesDto.UserRoles[i].RoleName</td> <-- this 'i' is OK
<td><div class="form-check m-1">
<input type="checkbox"
#bind="#manageUserRolesDto.UserRoles[copy].Selected" <-- i is not OK
/>
</div></td>
</tr>
}
The #bind is compiled to a lambda function that captures the variable.
Another option is to use a foreach() { } instead of a for() { }
Related
I'm new to ASP.NET Core and I'm working on a student management web app using razor pages. I created a test database in Microsoft SQL Server containing a table called JITStudents which I'm trying to display on a table on the students "Registration" and "Manage Student" pages.
I created a Models folder in which I have a class JITStudents:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
namespace JUI21.Models
{
public class JITStudents
{
[Key]
public int StudentID { get; set; }
[Required]
public string StdfirstName { get; set; }
[Required]
public string StdlastName { get; set; }
public int StdBirthDate { get; set; }
[Required]
public string Stdgender { get; set; }
public string StdPhone { get; set; }
[Required]
public string StdEmail { get; set; }
public string StdAddress { get; set; }
public string StdCity { get; set; }
public string StdState { get; set; }
public string StdZipCode { get; set; }
public string StdStatus { get; set; }
public List<JITStudents> GetJITStudentsParameters()
{
List<JITStudents> JITStudentsParameterList = new List<JITStudents>();
string connectionString = "Data Source=DESKTOP-IK1GLFJ\SQLEXPRESS;Initial Catalog=JITStuRegistry;Integrated Security=True";
SqlConnection con = new SqlConnection(connectionString);
string sqlQuery = "select JITStudentID, StdfirstName, StdlastName, StdBirthDate, Stdgender, StdPhone, StdEmail" +
"StdAddress, StdCity, StdState, StdZipCode, StdStatus";
con.Open();
SqlCommand cmd = new SqlCommand(sqlQuery, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr !=null)
{
while (dr.Read())
{
JITStudents JITStudentsParameter = new JITStudents();
JITStudentsParameter.StudentID = Convert.ToInt32(dr["StudentID"]);
JITStudentsParameter.StdfirstName = dr["StdfirstName"].ToString();
JITStudentsParameter.StdlastName = dr["StdlastName"].ToString();
JITStudentsParameter.StdBirthDate = Convert.ToInt32(dr["StdBirthDate"]);
JITStudentsParameter.Stdgender = dr["Stdgender"].ToString();
JITStudentsParameter.StdPhone = dr["StdPhone"].ToString();
JITStudentsParameter.StdEmail = dr["StdEmail"].ToString();
JITStudentsParameter.StdAddress = dr["StdAddress"].ToString();
JITStudentsParameter.StdCity = dr["StdCity"].ToString();
JITStudentsParameter.StdState = dr["StdState"].ToString();
JITStudentsParameter.StdZipCode = dr["StdZipCode"].ToString();
JITStudentsParameter.StdStatus = dr["StdStatus"].ToString();
JITStudentsParameterList.Add(JITStudentsParameter);
}
}
return JITStudentsParameterList;
}
}
}
Then, to the ManageStudent.cshtml.cs file I added the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc.RazorPages;
using JUI21.Models;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
namespace JUI21.Pages.Student
{
public class ManageStudentModel : PageModel
{
public List<JITStudents> JITStudentsParameterList = new List<JITStudents>();
public void OnGet()
{
JITStudents jitstudents = new JITStudents();
JITStudentsParameterList = jitstudents.GetJITStudentsParameters();
}
}
}
Unfortunately for me, trying to use the foreach (var JITStudents in Model.JITStudentsParameterList) statement to display the data on my table in the ManageStudent.cshtml as seen in the code below:
#page
#model JUI21.Pages.Student.ManageStudentModel
#{
}
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title brand-text font-weight-bold ">Manage Student</h3>
<div class="card-tools">
<div class="input-group input-group-sm" style="width: 150px;">
<input type="text" name="table_search" class="form-control float-right" placeholder="Search">
<div class="input-group-append">
<button type="submit" class="btn btn-default">
<i class="fas fa-search"></i>
</button>
</div>
</div>
</div>
</div>
<!-- /.card-header -->
<div class="card-body table-responsive p-0">
<table class="table table-hover text-nowrap">
<thead>
<tr>
<th>StudentID</th>
<th>StdfirstName</th>
<th>StdlastName</th>
<th>StdbirthDate</th>
<th>StdGender</th>
<th>StdPhone</th>
<th>StdEmail</th>
<th>StdAddress</th>
<th>StdCity</th>
<th>StdState</th>
<th>StdzipCode</th>
<th>StdStatus</th>
</tr>
</thead>
<tbody>
#{
if (Model !=null)
{
foreach (var JITStudents in Model.JITStudentsParameterList)
{
<tr>
<td> #JITStudents.StudentID</td>
<td> #JITStudents.StdfirstName</td>
<td> #JITStudents.StdlastName</td>
<td> #JITStudents.StdBirthDate</td>
<td> #JITStudents.Stdgender</td>
<td> #JITStudents.StdPhone</td>
<td> #JITStudents.StdEmail</td>
<td> #JITStudents.StdAddress</td>
<td> #JITStudents.StdCity</td>
<td> #JITStudents.StdState</td>
<td> #JITStudents.StdZipCode</td>
<td> #JITStudents.StdStatus</td>
</tr>
}
}
}
</tbody>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
</div>
Results in an error
'ManageStudentModel' does not contain a definition for 'JITStudentsParameterList' and no accessible extension method 'JITStudentsParameterList' accepting a first argument of type 'ManageStudentModel' could be found (are you missing a using directive or an assembly reference?)
For the registration page where I repeated the same data display process the error I get when clicking on the page from the nav menu is
One or more compilation references may be missing. If you're seeing this in a published application, set 'CopyRefAssembliesToPublishDirectory' to true in your project file to ensure files in the refs directory are published.
The type or namespace name 'RegistrationModel' does not exist in the namespace 'JUI21.Pages.Student' (are you missing an assembly reference?)
The type or namespace name 'RegistrationModel' does not exist in the namespace 'JUI21.Pages.Student' (are you missing an assembly reference?)
The type or namespace name 'RegistrationModel' does not exist in the namespace 'JUI21.Pages.Student' (are you missing an assembly reference?)
The type or namespace name 'RegistrationModel' does not exist in the namespace 'JUI21.Pages.Student' (are you missing an assembly reference?)
What did I do wrong how can I get it to work please help. For now, I'm just trying to display the records from the database on the table. If I can do so successfully, I'll like to move on to adding, updating, and deleting records on the database through the web app. The entire layout is complete and runs well when I manually enter records into the Html page like so;
#page
#model JUI21.Pages.Student.ManageStudentModel
#{
}
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title brand-text font-weight-bold ">Manage Student</h3>
<div class="card-tools">
<div class="input-group input-group-sm" style="width: 150px;">
<input type="text" name="table_search" class="form-control float-right" placeholder="Search">
<div class="input-group-append">
<button type="submit" class="btn btn-default">
<i class="fas fa-search"></i>
</button>
</div>
</div>
</div>
</div>
<!-- /.card-header -->
<div class="card-body table-responsive p-0">
<table class="table table-hover text-nowrap">
<thead>
<tr>
<th>StudentID</th>
<th>StdfirstName</th>
<th>StdlastName</th>
<th>StdbirthDate</th>
<th>StdGender</th>
<th>StdPhone</th>
<th>StdEmail</th>
<th>StdAddress</th>
<th>StdCity</th>
<th>StdState</th>
<th>StdzipCode</th>
<th>StdStatus</th>
</tr>
</thead>
<tbody>
<tr>
<td>183</td>
<td>John</td>
<td>Doe</td>
<td>04-24-1984</td>
<td>Male</td>
<td>505-875-1952</td>
<td>jdoe#gmail.com</td>
<td>15 Private Dr</td>
<td>Houston</td>
<td>TX</td>
<td>79105</td>
<td><span class="tag tag-success">Approved</span></td>
</tr>
<tr>
<td>219</td>
<td>Alexander</td>
<td>Pierce</td>
<td>9-14-1989</td>
<td>Male</td>
<td>702-875-1952</td>
<td>apierce#gmail.com</td>
<td>415 Gallileo St</td>
<td>Dallas</td>
<td>TX</td>
<td>79805</td>
<td><span class="tag tag-warning">Pending</span></td>
</tr>
<tr>
<td>657</td>
<td>Bob</td>
<td>Doe</td>
<td>04-24-1994</td>
<td>Male</td>
<td>813-891-7952</td>
<td>bdoe#gmail.com</td>
<td>1852 Mango Dr</td>
<td>Houston</td>
<td>TX</td>
<td>79105</td>
<td><span class="tag tag-primary">Approved</span></td>
</tr>
<tr>
<td>175</td>
<td>Caroline</td>
<td>Fru</td>
<td>12-07-1990</td>
<td>Female</td>
<td>818-952-0297</td>
<td>caro22#aol.com</td>
<td>5823 N Sunset Blvd</td>
<td>Los Angeles</td>
<td>CA</td>
<td>98716</td>
<td><span class="tag tag-danger">Denied</span></td>
</tr>
<tr>
<td>183</td>
<td>Jane</td>
<td>Doe</td>
<td>05-15-1988</td>
<td>Feale</td>
<td>575-435-0962</td>
<td>j8ne#gmail.com</td>
<td>115 4th St</td>
<td>San Antonio</td>
<td>TX</td>
<td>79415</td>
<td><span class="tag tag-success">Approved</span></td>
</tr>
<tr>
<td>219</td>
<td>Alex</td>
<td>Devoe</td>
<td>2-14-1984</td>
<td>Male</td>
<td>212-672-2846</td>
<td>adevoe#hotmail.com</td>
<td>8 Ball St</td>
<td>Silver Spring</td>
<td>MD</td>
<td>20104</td>
<td><span class="tag tag-warning">Pending</span></td>
</tr>
<tr>
<td>657</td>
<td>Olivia</td>
<td>Batupe</td>
<td>01-29-1978</td>
<td>Female</td>
<td>202-443-7869</td>
<td>olib1#gmail.com</td>
<td>4 Mimbo Dr</td>
<td>Laural</td>
<td>MD</td>
<td>20105</td>
<td><span class="tag tag-primary">Approved</span></td>
</tr>
<tr>
<td>175</td>
<td>Michael</td>
<td>Landis</td>
<td>08-07-1989</td>
<td>Male</td>
<td>505-322-8088</td>
<td>Mikel#aol.com</td>
<td>200 Mountain View Dr</td>
<td>Rio Rancho</td>
<td>NM</td>
<td>87144</td>
<td><span class="tag tag-danger">Denied</span></td>
</tr>
</tbody>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
</div>
Here is what it looks like when I run it;
UI image with manual entries
I'll like to get the app to look like this displaying records from the database instead.
Thanks for your help, anyone who can. I need guidance.
I Have a list of objects that i'm displaying, and i added a search box to filter a column, now when i enter a value, it works fine and the data is filtered.
The problem is, when i clear the search box, i don't get all the data back, i stay stuck with what i searched first, so i have to refresh every time i want to change the entered value or get the whole list.
Here's my Ts Code :
export class AdherentsComponent implements OnInit {
adherents: adherent[];
name: string;
constructor(private adherentService: AdherentService, private alertify: AlertifyService) { }
ngOnInit() {
this.getAdherents();
this.name = "";
}
getAdherents() {
this.adherentService.getAdherents().subscribe((
adherents: adherent[]) => {
this.adherents = adherents;
}, error => { this.alertify.error(error); })
}
Search() {
if (this.name.length > 0) {
this.adherents = this.adherents.filter(res => {
return res.nomcomplet.toLowerCase().match(this.name.toLowerCase());
})
}
else if (this.name.length === 0) {
this.adherents = this.adherents;
console.log(this.adherents.length);
}
}
}
Here's my Html Code :
<body >
<main role="main" class="container" >
<div class="jumbotron" style="background-color: white;">
<h2>Liste des Adhérents</h2>
<input type="text" [(ngModel)]="name" (input)="Search()" />
<table class="table table-hover">
<thead class="thead-light">
<tr>
<th>Nom Complet</th>
<th>Grade</th>
<th>Poste</th>
<th>Telephone</th>
<th>E-mail</th>
<th></th>
</tr>
</thead>
<tr *ngFor="let item of adherents">
<td>{{item.nomcomplet}}</td>
<td>{{item.grade}}</td>
<td>{{item.poste}}</td>
<td>{{item.telephone}}</td>
<td>{{item.email}}</td>
<td><button [routerLink]="['/adherents/', item.id]" style="margin-right: 0.2em;" title="Details" class="btn-sm btn-secondary text-white"><i class="fa fa-eye"></i></button>
<button [routerLink]="['/adherentEdit/', item.id]"
style="margin-right: 0.2em;" title="Modifier" class="btn-sm btn-primary text-white"><i class="fa fa-edit"></i></button></td>
</tr>
</table>
</div>
</main>
</body>
Please how can i modify The Search() Function so i can dynamically get data from the Array when changing the value in the search box input ?
Use a different variable for all the values and another one for the values that are displayed to the user. When you search you filter all elements and save them into the array that you are using to display to the user. Same occurs when you clear searchbox, simply get all values and save them to this array.
You are replacing the value in the property _adherents that contains all the values with a new value.
Instead you could
make _adherents private.
Create another property current_adherents that represents an array of your filtered/sorted output.
Use current_adherents in your template.
example code
export class AdherentsComponent implements OnInit {
private _adherents: adherent[];
public current_adherents: adherent[];
name: string;
// removed code irrelevant to the question
Search() {
this.current_adherents = this._adherents.filter(res => {
return res.nomcomplet.toLowerCase().match(this.name.toLowerCase());
})
}
}
Edit: if name is an empty string by definition it will match all elements. So you could remove your if/else logic too ;).
I want to add radio button values to my SQL table using ASP.NET MVC framework. I have a table with columns Approachability, Speed, Quality, and these three columns have to store the following values
Satisfied, Very Satisfied, Unsatisfied
so I am using the radio button for the values, but I don't know how to add the radio button value to the table please anyone help me.
Code that I have tried so far:
public class Customer
{
[Required]
public string Approachability { get; set; }
[Required]
public string Speed { get; set; }
[Required]
public string Quality { get; set; }
}
Controller:
[HttpGet]
public IActionResult AddCustomer()
{
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult AddCustomer([Bind] Customer cust)
{
if (ModelState.IsValid)
{
objproject.AddCustomer(cust);
return RedirectToAction("Index");
}
return View(cust);
}
Database access:
public void AddCustomer(Customer cust)
{
using (SqlConnection con = new SqlConnection(connectionstring))
{
SqlCommand cmd = new SqlCommand("spAddCustomer", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("#Approachability", cust.Approachability);
cmd.Parameters.AddWithValue("#Speed", cust.Speed);
cmd.Parameters.AddWithValue("#Quality", cust.Quality);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
Finally my view is:
<div class="col-md-10 offset-md-2">
<div class="row pt-2 row-space">
<div class="col-md-7">
<table class="table">
<thead>
<tr>
<th></th>
<th>Very Satisfied</th>
<th>Satisfied</th>
<th>Unsatisfied</th>
</tr>
</thead>
<tbody>
<tr>
<td>Approachability</td>
<td><input class="approachgroup" type="radio" asp-for="Approachability"name="approachgroup" value="Very Satisfied"></td>
<td><input class="approachgroup" type="radio" asp-for="Approachability" name="approachgroup" value="Satisfied"></td>
<td><input class="approachgroup" type="radio" asp-for="Approachability" name="approachgroup" value="UnSatisfied"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
For example, I am including only one field radio button
Okay, so regarding your specific case while there are solutions to use asp-for="SomeField", you can just match a view model field with the radio button's name field:
<tr>
<td>Approachability</td>
<td><input class="approachgroup" type="radio" name="Approachability" value="Very Satisfied"></td>
<td><input class="approachgroup" type="radio" name="Approachability" value="Satisfied"></td>
<td><input class="approachgroup" type="radio" name="Approachability" value="UnSatisfied"></td>
</tr>
When you submit your form, Approachability is populated with value of the checked radio button.
In my Angular program, I'm trying to filter an array based on another array. I want to only display the name of people (from empInfo array) that have a value of etoEarned for the type property in the ptoData array. The empInfo array is a list of all of the employees with their employee details and the ptoData array is a list of all of the days that anyone has taken off. There is an EmpKey field in both arrays that says which employee has taken which days off. Right now, it's displaying everyone and only filling in values for those who have them and looks like this:
How can I eliminate the names that don't have any allocated hours?
Here's functions that my button calls:
setValues(): void {
this.datePTO = this.ptoData.filter(pto => pto.date > this.StartDate && pto.date < this.EndDate);
this.etoEarned = this.datePTO.filter(pto => pto.type === 'etoEarned');
setTimeout(() => { this.printMonthlyReport() }, 2000);
}
printMonthlyReport(): void {
let printContents, printAdjContents, popupWin, popupWinAdj;
printAdjContents = document.getElementById('print-monthly-eto-report').innerHTML;
popupWinAdj = window.open('', '_blank', 'top=0,left=0,height=100%,width=auto');
popupWinAdj.document.open();
popupWinAdj.document.write(`
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<title>Monthly Adjusted Report</title>
</head>
<body>
${printAdjContents}
</body>
</html>`
);
}
and here's my html:
<div id="print-monthly-eto-report" style="border: none; display: none;">
<div class="panel-body col-sm-12" *ngFor="let emp of empInfo">
<div *ngIf="empHasEto(emp)>
<table class="table">
<thead>
<tr>
<td colspan="4" style="font-weight: bold;">Employee: {{emp.FirstName}} {{emp.LastName}}</td>
</tr>
<tr>
<td>Date</td>
<td>Hours</td>
<td>Scheduled</td>
<td>Notes</td>
</tr>
</thead>
<tbody>
<ng-container *ngFor="let eto of etoEarned">
<tr *ngIf="eto.EmpKey === emp.EmpKey">
<td>{{eto.date | date: 'MM/dd/yyyy'}}</td>
<td>{{eto.hours}}</td>
<td>{{eto.scheduled}}</td>
<td>{{eto.notes}}</td>
</tr>
</ng-container>
</tbody>
<tfoot>
<tr>
<td colspan="4"><span style="font-weight:500;">Total ETO Hours Earned: {{emp.ETOEarned}}</span></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
EDIT - I've added a function (thanks to #LarsMontanaro) and it has fixed the problem of displaying everyone's name, but still leaves space for each person. I'm assuming the problem is my html because I have let emp of empInfo before *ngIf="empHasEto(emp) so it will still go through each person but only display the table for those who return true. How can I fix this to eliminate the white space? (for reference here's what it looks like):
Also, here's my new function (I've updated the .html above):
empHasEto(emp: EmpInfo) {
this.datePTO = this.ptoData.filter(pto => pto.date > this.StartDate && pto.date < this.EndDate);
this.etoEarned = this.datePTO.filter(pto => pto.type === 'etoEarned');
if (this.empInfo && this.etoEarned) {
for (let eto of this.etoEarned) {
if (eto.EmpKey == emp.EmpKey) {
return true;
}
}
}
}
EDIT:
A better way of doing this is to use a pipe, to filter the array that you are iterating over.
You can create a custom pipe like so:
import { Pipe, PipeTransform } from '#angular/core';
#Pipe({
name: 'filterEmployeesByEto'
})
export class FilterEmployeesByEtoPipe implements PipeTransform {
transform(empArray : Array<any>, etoArray : Array<any>): Array<any> {
if (empArray && etoArray) {
return empArray.filter((emp) => {
for (let eto of etoArray) {
if (eto.EmpKey === emp.EmpKey) {
return true;
}
}
}
}
}
}
and then call your pipe in the html line containing the *ngFor like so:
<div class="panel-body col-sm-12" *ngFor="let emp of empInfo | filterEmployeesByEto : etoEarned">
You will have to register your pipe in your app-module.ts.
A SO post which explains this exact process in more detail is here: How to apply filters to *ngFor
And you can read about Angular Custom Pipes here: https://angular.io/guide/pipes#custom-pipes
I am try to get count of row of a web page table but I am getting dimension of the table.
I have file called TableRow class and this class using properties file "webelement.properties" .In properties file i have kept the path of web element
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class TableRow {
protected static WebDriver driver;
#BeforeClass
public static void setup() {
driver = new FirefoxDriver();
driver.get("some url");
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.manage().window().maximize();
}
public Properties getWebElementDetails() throws IOException {
Properties p = new Properties();
// Read object repository file
InputStream stream = new FileInputStream(
new File(System.getProperty("user.dir") + "//src//com//properties//webelement.properties"));
p.load(stream);
return p;
}
public WebElement getElementByXPath(String Key) throws IOException {
Properties propertiesValue = getWebElementDetails();
try {
return driver.findElement(By.xpath(propertiesValue.getProperty(Key)));
} catch (Throwable t) {
// If element not found on page then It will return null.
return null;
}
}
#Test()
void testLogincase1() throws Exception{
Thread.sleep(2000);
System.out.println(getElementByXPath("tab")).getsize());
}
}
webelement.properties
tab=.//*[#id='LinkedForm_Organization_OfficeChild']/div[2]/div[1]/div/table/tbody/tr
HTML COde.
<div class="row">
<div class="column">
<table class="linked-record-table data-table">
<thead>
<tr>
<th>Details</th>
<th>Name</th>
<th>Address 1</th>
<th>Address 2</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
</tr>
</thead>
<tbody>
<tr class="data-row" data-is-new="false">
<input id="Organization_OfficeChild_R1_" type="hidden" value="1" name="Organization_OfficeChild_R1_"/>
<input id="Organization_OfficeChild_R1__pky" type="hidden" value="4223" name="Organization_OfficeChild_R1__pky"/>
<td>
<a class="link darker" href="/Office/Details/4223?mode=Edit&_fcl=Organization&_fky=2291">
</td>
<td>
<td>
<td>
<td>
<td>
<td>
</tr>
<tr class="data-row" data-is-new="false">
<tr class="data-row new-row-template" data-is-new="true">
<tr class="data-row new-row-template" data-is-new="true">
<tr class="data-row new-row-template" data-is-new="true">
</tbody>
</table>
</div>
What i am doing wrong . Please provide solutions.
Hi please identify the row and column of the table as below
List<WebElement> myrowcount = driver.findElements(By.xpath("//*[#class='linked-record-table data-table']/tbody/tr"));
System.out.println("Size of the row is : " + myrowcount.size());
List<WebElement> mycolumncount = driver.findElements(By.xpath("//*[#class='linked-record-table data-table']/tbody/tr/td"));
System.out.println("Size of the column is : " + mycolumncount.size());