Не видит параметры DataSourse

tasha klemer

Люди добрые, разьяните что упущенно из вида?есть DataSourse -
<asp:SqlDataSource ID="SDDiplAll" runat="server" 
 ConnectionString="<%$ ConnectionStrings:WEBConnectionString %>" 
 
 SelectCommand="SELECT [IdDipl], [IdWorker], [IdSchool], [NameDipl], [NomDipl], [DatDipl], [pk], [DataF] FROM [Diploma] WHERE ([IdWorker] = @IdWorker)" 
 
 InsertCommand="INSERT INTO Diploma(IdWorker, IdSchool, NameDipl, NameCourse, NomDipl, DatDipl, Dat1, Dat2, Price, pk, DataF) VALUES (@IdWorker, @IdSchool, @NameDipl, @NameCourse, @NomDipl, @DatDipl, @Dat1, @Dat2, @Price, @pk, @DataF" 
 DeleteCommand="DELETE FROM Diploma WHERE (IdDipl = @IdDipl)" 
 onselecting="SDDiplAll_Selecting">
 <DeleteParameters>
 <asp:ControlParameter ControlID="FormView2" Name="IdDipl" 
 PropertyName="SelectedValue" />
 </DeleteParameters>
 <InsertParameters>
 <asp:ControlParameter ControlID="FormView2" Name="IdWorker" 
 PropertyName="SelectedValue" />
 <asp:Parameter Name="IdSchool" />
 <asp:Parameter Name="NameDipl" />
 <asp:Parameter Name="NameCourse" />
 <asp:Parameter Name="NomDipl" />
 <asp:Parameter Name="DatDipl" />
 <asp:Parameter Name="Dat1" />
 <asp:Parameter Name="Dat2" />
 <asp:Parameter Name="Price" />
 <asp:Parameter Name="pk" />
 <asp:Parameter Name="DataF" />
 </InsertParameters>
 <SelectParameters>
 <asp:ControlParameter ControlID="FormView2" DefaultValue="0" Name="IdWorker" 
 PropertyName="SelectedValue" Type="Int32" />
 </SelectParameters>
 </asp:SqlDataSource>
в коде задаются например -selectparametr
DropDownList ddl2 = FormView2.FindControl("DropDownList2") as DropDownList;

 SDDiplAll.SelectParameters["IdWorker"].DefaultValue = ddl2.SelectedValue.ToString();
 SDDiplAll.DataBind();
при втором SelectedIndexChanged gridView ввозвращает пустой набор строк. Я посомтрела парпметр передается или нет, параметр передается!
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
 {

 DropDownList ddl2 = FormView2.FindControl("DropDownList2") as DropDownList;
 SDDiplAll.SelectParameters["IdWorker"].DefaultValue = ddl2.SelectedValue.ToString();
 SDDiplAll.DataBind();
 
 SDEditDiplom.SelectCommand = "SELECT [IdDipl], [IdSchool], [IdWorker], [NameDipl], [NameCourse], [NomDipl], [DatDipl], [Dat1], [Dat2], [Price], [pk], [DataF] FROM [Diploma] WHERE [IdDipl] = " + Convert.ToInt32(GridView1.SelectedDataKey["IdDipl"]);
 SDEditDiplom.DataBind();
 
 Session["sWorker"] = Convert.ToString(GridView1.SelectedDataKey["IdWorker"]);
 Session["sDipl"] = Convert.ToString(GridView1.SelectedDataKey["IdDipl"]);

 if (FormView2.CurrentMode == FormViewMode.Insert)
 { this.FormView2.ChangeMode(FormViewMode.Edit); }
 }
4 ответа

tasha klemer

tasha klemer,"@"


tasha klemer

VIT2708,SelectCommand="SELECT [IdDipl], [IdWorker], [IdSchool], [NameDipl], [NomDipl], [DatDipl], [pk], [DataF] FROM [Diploma] WHERE ([IdWorker] = @IdWorker)"вы это имеете ввиду?


tasha klemer

tasha klemer,SqlDataSource.SelectParametrs.Add("IdWorker", DbType.String, "Worker")илиstring conn = ConfigurationManager.ConnectionStrings["строка подключения"].ConnectionString; using (SqlConnection sqlConn = new SqlConnection(conn)) { SqlCommand cmd = new SqlCommand("название хранимой процедуры", sqlConn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@IdWorker", RadTextBox1.Text); ....... SqlParameter name = new SqlParameter("@IdWorker", SqlDbType.NVarChar, 150); }sqlConn.Open(); cmd.ExecuteNonQuery(); sqlConn.Close();


tasha klemer

tasha klemer,и вообще у меня была похожая проблема вот ссылка, может поможет[url=]http://www.sql.ru/forum/actualthread.aspx?tid=932097[/url]