Values passed to
PRINT
in your stored procedure will
not be part of any result-set. Only values returned as part of a
SELECT
statement will appear in your
DataTable
.
You
could fix the stored procedure:
CREATE PROC getQuantityUpTo100
As
BEGIN
SELECT TOP 101
ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) - 1 As N
FROM
sys.all_columns
;
END
However, since you're just returning a list of numbers from 0 to 100, you don't
need a stored procedure. Make sure you have a reference to the
System.Core
assembly, and a
using System.Linq;
statement at the top of your code file, and then use:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
var ddl = (DropDownList)e.Row.FindControl("myDropDownList");
ddl.DataSource = Enumerable.Range(0, 101);
ddl.DataBind();
}
}
Since the list is static, and trivial to recreate on post-back, you could reduce the size of your
ViewState
by binding the list in the control's
Init
event, rather than the
GridView
's
RowDataBound
event:
<asp:DropDownList ID="myDropDownList" runat="server"
AutoPostBack="true"
Style="width: 350px;"
OnInit="BindMyDropDownList"
OnSelectedIndexChanged="myDropDownList_SelectedIndexChanged"
/>
protected void BindMyDropDownList(object sender, EventArgs e)
{
var ddl = (DropDownList)sender;
ddl.DataSource = Enumerable.Range(0, 101);
ddl.DataBind();
}