none
使用objectDataSource控件获取cookie的username值 RRS feed

全部回复

  • 你好,

    根据你的描述,你的问题是asp.net 的控件问题,我帮你把帖子移到asp.net 论坛,会有助于解决你的问题。

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    2018年4月20日 7:38
  • 你好,

    据我所知,obejctDataSource控件是用于数据绑定的。

    我不清楚你获取cookie的username的值是什么意思。

    你的需求是根据cookie的username的值从数据库来得到数据吗?

    如果需求是这样我建议你可以在后台绑定数据源。

    具体的你可以参照如下代码:

    protected void BindDetailsView()
        {
            ObjectDataSource obj = new ObjectDataSource();
            dvwCurrComment.DataSource = obj;
            obj.TypeName = TypeName;
    
            obj.SelectMethod = "GetCommentByID";
            obj.SelectParameters.Add(new Parameter("commentID", DbType.Int32, "-1") );
    
            obj.InsertMethod = "InsertComment";
            try
            {
                obj.InsertParameters.Add(new Parameter("cottageID", DbType.Int32, Request["ID"]));
            }
            catch (System.Exception e)
            {
                throw new NotSupportedException("Parameter ID must be specified in URL");
            }
            obj.InsertParameters.Add(new Parameter("addedBy", DbType.String, ""));
            obj.InsertParameters.Add(new Parameter("addedByAvatarUrl", DbType.String, ""));
            obj.InsertParameters.Add(new Parameter("body", DbType.String, ""));
    
            obj.DeleteMethod = "DeleteComment";
            obj.DeleteParameters.Add(new Parameter("commentID", DbType.UInt32, "-1"));
    
            obj.UpdateMethod = "UpdateComment";
            obj.UpdateParameters.Add( new Parameter("id", DbType.Int32, "-1"));
            obj.UpdateParameters.Add( new Parameter("body", DbType.String, ""));
        }


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2018年4月20日 9:12