So I´m trying to create a registration page for a website where the User can register a number questions and answers. Users´ information is already on the app´s database (The number of questions the user needs to answer to register). So for example I have two users user1 and user2 each with 2 and 3 questions to register respectively. The questions are can be chosen from a dropdown list and below it there is a textbox to answer it.
So my question is, how do I populate the page for each respective user? user1 should have 2 DDLs and textboxes and user2 3 DDLs and textboxes. The reason for this is that users belong to different groups and thus have different requirements to register. I have seen from this page and this page that I may have to write my own engine?
Here is my aspx code:
<asp:ListView runat="server" ID="RegisterListView" DataKeyNames="Id" Visible="true" >
<LayoutTemplate>
<table id="tblRegister"
style="width: 460px; background-color: lightgray" border="1">
<tr runat="server" id="itemPlaceholder">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td colspan="2">
<asp:DropDownList ID="RegisterQuestionList" runat="server" SelectMethod="RegisterQuestionList_GetData" />
</td>
</tr>
<tr runat="server">
<td colspan="2">
<asp:TextBox runat="server" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
And here is my behind-code, which on pageload retrieves the user specific number of questions and the GetData method populates the drop down lists:
protected void Page_Load(object sender, EventArgs e)
{
using (var db = new AppContext())
{
var userID = Convert.ToInt32(Request.QueryString["User"]);
userID = 9;
var currentUser = db.Users.Find(userID);
numQuestions = currentUser.NumQuestionsRegister;
}
}
public IQueryable<QuestionPool> RegisterQuestionList_GetData()
{
var db = new AppContext();
var questions = db.QuestionsPool;
return questions;
}
Some advise on how to approach this would be greatly appriciated. Thank you.