Click here to Skip to main content
15,112,662 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to create web application with multiple textbox insert to db (dynamic)

- First: I've bind question from my db and display it in Listview;
- Question: I would like to have textbox together with my question in the listview for Answer.

(If query and found 4 question then program should create 4 textbox for answer to each question)

Then in web application (Front) - clint input answer and click sumbit to update to data in the different table.

I really have issue with the multiple textbox return value then Insert to db table. Any Idea what I should read or Any function should I use.

What I have tried:

private void BindQuestion()
    SqlConnection sqlcon = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=master;");
    SqlDataAdapter sqlda = new SqlDataAdapter("Select * from dbo.Question", sqlcon);

    DataTable dtbl = new DataTable();

    dlExam.DataSource = dtbl;


<asp:DataList ID="dlExam" runat="server" DataMember="QID" BackColor="#F0F0F0">
                <table width="800">
                        <td align="left">
                            (<%#Container.ItemIndex+1 %>)  <asp:Label ID="QID" runat="server" Text='<%# Eval("Question") %>'></asp:Label>
                            <asp:Label ID="lblQuestionId" runat="server" Text='<%# Eval("QID") %>' Visible="false"></asp:Label>
                        <td align="left">
                           <asp:TextBox ID="rblAnswers" runat="server"></asp:TextBox>  
                  <asp:TextBox ID="Textbox" Style="width: 100px; background-color: white;" 
                                runat="server" CausesValidation="true" />



CommandArgument='<%# Eval("ID") %>
is not work for multiple textbox or dynamic textbox.

Thank you.!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900