Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72473

How to get Textarea values in Razor(blazor) component, if Textarea is generated under foreach loop dynamically for more then once

$
0
0

can anyone please help to get the Textarea values from Razor component if Textarea generated under foreach loop dynamically for more then once.

I have tried with @bind-Value and value but still not able to get all Textareas values individually.

Razor component code
<EditForm Model="@userans" OnValidSubmit="@oninput">
    <DataAnnotationsValidator />
    <h3>Test </h3>


    @if (Questiontable == null)
    {

        <p><em>Loading...</em></p>
    }
    else
    {
        <table class="table">
            <thead>
                <tr>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Questiontable[0].Questiondata)
                {
                    <tr>
                        <td>@item.Question</td>
                    </tr>
                    <tr>
                        <th>
                            **<textarea id="TextArea1" rows="2" cols="20" @bind="@userans.answers"></textarea>**
                        </th>
                    </tr>
                }
            </tbody>
        </table>
        <div align="center">
            <button class="btn btn-primary" type="submit" @onclick="btnnextclick">Next</button>
        </div>
    }
</EditForm>

Razor component is loading data coming from database and generating Textarea as many as database records but as soon as im updating Textarea, i need to get all values available in different Textareas.


Viewing all articles
Browse latest Browse all 72473

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>