---
title: "DropDownList not getting populated from Stored Procedure"  
description: "DropDownList not getting populated from Stored Procedure"  
author: "Pravesh Singh"  
published: 2014-08-28  
updated: 2014-08-28  
canonical: https://www.mindstick.com/forum/2190/dropdownlist-not-getting-populated-from-stored-procedure  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# DropDownList not getting populated from Stored Procedure

I have a [dropDownList](https://www.mindstick.com/articles/324837/how-to-bind-dropdownlist-in-mvc-core-from-database-using-entity-framework) that I'm [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to get populated with id's from a [stored procedure](https://www.mindstick.com/articles/803/using-stored-procedure-in-asp-dot-net). However it doesn't seem to work. this is my dropDownlist:

```
 <div id="newExpenseTypeDialog" style="display:none;">        <label>Select new CaseFile:</label>        <asp:DropDownList runat="server" ID="ddlCaseFiles" DataSourceID="dsMyCaseFiles" DataTextField="Display" DataValueField="FileID" OnPreRender="ddl_PreRender" Width="524px" /></div>
```

And this is my [DataSource](https://www.mindstick.com/blog/447/listing-the-databases-connected-to-the-datasource):

```
<asp:SqlDataSource ID="dsMyCaseFiles" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="System.Data.SqlClient" SelectCommand="p_CaseFiles_ListActiveCaseFilesAssignedTo" SelectCommandType="StoredProcedure">    <SelectParameters>        <asp:SessionParameter Name="InvestigatorID" SessionField="InvestigatorID" />        <asp:SessionParameter Name="AssignedTo" SessionField="InvestigatorID" />    </SelectParameters></asp:SqlDataSource>
```

My Stored procedure needs two parameter. InvestigatorID and AssignedTo. It will then find return all the FileID's that match.

**[Now](https://yourviews.mindstick.com/view/81402/it-s-liberals-vs-progressives-in-us-politics-now) this is my .aspx.cs [side code](https://www.mindstick.com/forum/143/close-popup-window-by-server-side-code) : (Page_load)**

```
if (Request.QueryString["ExpenseID"] != null)    {        if (!IsPostBack)        {            ddlCaseFiles.DataSourceID = "dsCaseFiles";            ddlCaseFiles.DataTextField = "Display";            ddlCaseFiles.DataValueField = "FileID";        }    }
```

and my Pre_Render:

```
protected void ddl_PreRender(object sender, EventArgs e){    DropDownList ddl = (DropDownList)sender;    try    {        if (ddl.Items[0].Value != "-1")            ddl.Items.Insert(0, new ListItem("--Select--", "-1"));    }    catch    {        ddl.Items.Insert(0, new ListItem("--Select--", "-1"));    }}
```

The list has the pre_render working and what not, just no [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) from my stored procedure.

## Replies

### Reply by Sumit Kesarwani

Hi Pravesh,

You haven't Binded your dropdown list yet

```
if (Request.QueryString["ExpenseID"] != null){    if (!IsPostBack)    {       
ddlCaseFiles.DataSourceID = "dsCaseFiles";       
ddlCaseFiles.DataTextField = "Display";       
ddlCaseFiles.DataValueField = "FileID";       
ddlCaseFiles.DataBind();  //You need to Bind it here    }}
```

Hope this will help you


---

Original Source: https://www.mindstick.com/forum/2190/dropdownlist-not-getting-populated-from-stored-procedure

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
