1

Actually, I have a table format layout to display the timing information of clicnic operating Hours. I have an edit button in that table. Each row has an id property called sysId. So when I click edit, it redirects to the editing page. My editing page will look like the below image:

img

Code to display Clinic Operating hours

    @using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
       <div class="table-responsive">
                        <table class="table table-bordered" id="sample_editable_1">
                            <thead>
                                <tr>
                                    <th style="display:none;">Id</th>
                                    <th>Day</th>

                                    <th>Morning Start Time</th>
                                    <th>Morning End Time</th>
                                    <th>Afternoon Start Time</th>
                                    <th>Afternoon End Time</th>
                                    <th>Evening Start Time</th>
                                    <th>Evening End Time</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
  <tbody>
            @foreach (var item in Model.ProviderWrkHours)
               {
                   <tr>
                   <td style="display:none;">@item.SysID</td>
                   <td>@item.DayType</td>
                   <td contenteditable="true" style="text-align: center;">@item.MorningStartTime</td>
                   <td contenteditable="true" style="text-align: center;">@item.MorningEndTime</td>                                           @*      <td contenteditable="true">@item.MorningEndTime</td>*@
                    <td contenteditable="true" style="text-align: center;" @*id="editor"*@>@item.AfterNoonStartTime</td>
                   <td contenteditable="true">@item.AfterNoonEndTime</td>
                   <td contenteditable="true" style="text-align: center;">@item.EveningStartTime</td>
                   <td contenteditable="true">@item.EveningEndTime</td>
                   <td style="color:#0026ff">
                    @Html.ActionLink(" Edit", "UpdateTimings", "ClinicTimings", new { sysid = item.SysID }, new { @class = "fa fa-pencil" })
                    </td>
                    </tr>
                    }
                   </tbody>
</table>
</div>
}

So how can I access the next sysid information (I mean next row information of table) when I click the right arrow using some javascript from the current page.

2
  • Please update your question with rendered html and also add html for your arrow mark element.. Commented Feb 2, 2017 at 3:32
  • For arrow mark i am using livicon @GuruprasadRao Commented Feb 2, 2017 at 3:53

1 Answer 1

2

You may use this code (not the exact one) in controller.

ViewBag.Next =  model.DBTable()
               .Select(m => m.ID)
               .OrderBy(m => m.ID)
               .Where(x=> x.Id > id)
               .FirstOrDefault()
               .ToString();

ViewBag.Previous =  model.DBTable()
               .Select(m => m.ID)
               .OrderByDesc(m => m.ID)
               .Where(x=> x.Id < id)
               .FirstOrDefault()
               .ToString();
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot @jaber

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.