hi Experts,
my scenario is i have two different tables and i want bind in dropdown according to user Id....
- <body>
- <form id="form1" runat="server">
- <div>
- <table>
- <tr>
- <td>Security Question1</td>
- <td>
- <asp:DropDownList ID="ddlQuestion" runat="server" AppendDataBoundItems="true">
- </asp:DropDownList>
- <asp:TextBox ID="TxtAnswer" runat="server"></asp:TextBox>
- </td>
- <tr>
- <td>
- <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
- </td>
- </tr>
- <tr>
- <td>
- <asp:Label ID="lblerror" runat="server"></asp:Label>
- </td>
- </tr>
- </table>
- </div>
- </form>
- </body>
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- bindSecQue();
- }
- }
- private void bindSecQue()
- {
- using (schoolEntities6 context = new schoolEntities6())
- {
- List<SecurityModel> newlist = (from c in context.SecurityQuestionDetails
- join sq in context.SecurityQuestions on c.SecQueId equals sq.Id
- where c.UserId == Id
- select new SecurityModel
- {
- Id = c.Id,
- SecQue = sq.SecQue,
- SecQue2 = sq.SecQue2,
- SecQueId = c.SecQueId
- }).ToList();
- ddlQuestion.DataTextField = "SecQue";
- ddlQuestion.DataValueField = "SecQueId";
- ddlQuestion.DataBind();
- ddlQuestion.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Select"));
- }
- }
I am using this scenario but didn't show any data in frontend...and when I give static UserId == 1..it's showing...