How to set parameters for SqlDataSource UpdateCommand

淺唱寂寞╮ 提交于 2019-12-02 12:39:21

You can set them something like this :

Example : In the example MPID is the sql parameter name @MPID

<UpdateParameters>                    
    <asp:ControlParameter Name="MPID" ControlID="MPID_TextBox" PropertyName="Text  />  
    <asp:ControlParameter Name="User_Id" ControlID="User_Id_TextBox" PropertyName="Text  />  
</UpdateParameters> 

Correction: Just spotted your proc param names so it must be

<asp:ControlParameter Name="in_MPID" ...............
<asp:ControlParameter Name="in_User_Id" ...............

Hope this helps....

I really wouldn't use a SqlDataSource. It will be much easier if you make the call to the database in the code-behind (or a better yet in a Data Access Layer).

If you use a SqlDataSource the stored procedure call will only be available on that page. Every time you want to make that same call you will have to copy and paste the SqlDataSource or make a UserControl out of it.

The following example uses the Entity Framework to connect to the database and retrieve records:

public List<Record> GetAllRecordsByUserName(string credentials)
{
    List<Record> recordList;
    using (CustomEntities context = new CustomEntities())
    {

        IQueryable<Section> recordQuery = from records in context.Records
                                              where records.UserName == credentials
                                              select records; 
        recordList = recordQuery.ToList<Record>();
    }
    return recordList;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!