here is my scenario:
Iv linked a parameter of my sqlds to a dropDownList (dropDownList.selectedValue), but i want it so that when the selected item is "" (an item with no text is added on pageload, to let the user select a null value, sort of), i want the sqlds to pass null. Here is what i tried, but it doesnt开发者_StackOverflow中文版 work (gave the error saying no such parameter existed:
protected void sqldsNewItem_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
DropDownList ddl = dwNewItem.FindControl("ddlEffects") as DropDownList;
if (ddl.SelectedItem.Text == "")
{
e.Command.Parameters["effect"].Value = null;
e.Command.Parameters["numberOfTurns"].Value = null;
}
}
(I used FindControl because the dropDownList in question is in a template.)
And here is how i bound it to the sqlds in the first place:
<asp:ControlParameter ControlID="dwNewItem$ddlEffects" Name="effect" PropertyName="SelectedValue"
DbType="int64" />
Thanks guys!
精彩评论