你可以这样设置它们:
示例:示例中 MPID 是 sql 参数名称@MPID
<UpdateParameters>
<asp:ControlParameter Name="MPID" ControlID="MPID_TextBox" PropertyName="Text" />
<asp:ControlParameter Name="User_Id" ControlID="User_Id_TextBox" PropertyName="Text" />
</UpdateParameters>
更正:刚刚发现你的过程参数名称,所以它一定是
<asp:ControlParameter Name="in_MPID" ...............
<asp:ControlParameter Name="in_User_Id" ...............
我真的不会使用
SqlDataSource
。如果您在代码隐藏中(或者更好的是在数据访问层中)调用数据库,则会容易得多。
如果您使用
SqlDataSource
,则存储过程调用将仅在该页面上可用。每次您想要拨打相同的电话时,您都必须复制并粘贴 SqlDataSource
或从中创建 UserControl
。
以下示例使用实体框架连接到数据库并检索记录:
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;
}