Romacali
asked on
dynamic ddl
HI,
I have a ddl in my page that should get the values from the database table type?
I'm new to ASP.net
how can I add it to my page?
so far I hardcode as:
I have a ddl in my page that should get the values from the database table type?
I'm new to ASP.net
how can I add it to my page?
so far I hardcode as:
<asp:DropDownList ID="ddlEvaluationType" runat="server" CssClass="ddl">
<asp:ListItem Value="1" >Program Begin</asp:ListItem>
<asp:ListItem Value="2" >Program End</asp:ListItem>
<asp:ListItem Value="3" >6 Months</asp:ListItem>
</asp:DropDownList>
ASKER
I think the sqldatasource control placed directly on the aspx page is easier :)
thanks
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I will try it out
ASKER
ok..
now the value is not saving.. Now can I save it?
I had this code:
cmd3.Parameters.Add(new SqlParameter("@EvaluationI D", ddlEvaluationType.Selected Value));
now the value is not saving.. Now can I save it?
I had this code:
cmd3.Parameters.Add(new SqlParameter("@EvaluationI
I would have to see your code for saving.
Actually looking at it. You probably need to convert the selected value to an integer type for your save.
It's important that you match your database datatype to the type you're passing to your stored proc.
More than likely your storing the EvaluationTypeId as an integer in the database. ddlEvaluationType.Selected Value returns a type string so convert.
cmd3.Parameters.Add(new SqlParameter("@EvaluationI D", Convert.ToInt32(ddlEvaluat ionType.Se lectedValu e));
It's important that you match your database datatype to the type you're passing to your stored proc.
More than likely your storing the EvaluationTypeId as an integer in the database. ddlEvaluationType.Selected
cmd3.Parameters.Add(new SqlParameter("@EvaluationI
You can use an sqldatasource control placed directly on the aspx page
OR
you can use the code behind file to retrieve data from the database, set the ddl's datasource property and call databind() on the dropdown list
Which way do you want to know?