我怎么可以访问.aspx文件.aspx.cs文件的字符串变量值 [英] how can i access string variable value of .aspx.cs file in .aspx file

查看:265
本文介绍了我怎么可以访问.aspx文件.aspx.cs文件的字符串变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时得到一个字符串值回归为<$ C C>回归=(会话[回归])的ToString(); 在.aspx.cs文件,然后我想用这个在SqlDataSource的财产的SelectCommand .aspx文件值,如下

i m getting a string value regression as regression = (Session["Regression"]).ToString(); in .aspx.cs file then i want to use this value in .aspx file in SelectCommand of SqlDataSource property as below

SelectCommand="SELECT [issue_oid], [issue_num], [regression], 
            [status], [tested_by], [tested_on], [patch_name], [arrived_on], [previous_info], [comment], [is_duplicate] FROM [itt_monthly_patch_issue_list] where status='Not Tested' and `regression='<%#regression%>'"`

.aspx.cs文件Page_Load方法是如以下

.aspx.cs file page_load method is as below

 protected void Page_Load(object sender, EventArgs e)
    {
            if ((Session["UserName"].ToString()) == string.Empty)
            {
                Server.Transfer("regressionType.aspx");
            }
            regression = (Session["Regression"]).ToString();
            usrname = (Session["UserName"]).ToString();
            DataBind();
     }

请建议我如何能做到这一点?
在此先感谢...

please suggest me how can i do this? thanks in advance...

推荐答案

您可以您会话变量在你的SqlDataSource值。像这样的例子。

You can you Session Variable's value in your SQLDatasource. Like this Example.

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:testDatabaseConnectionString %>"
    SelectCommand="SELECT * FROM [UserTable] WHERE ([userID] = @UserID)">
    <SelectParameters>
        <asp:SessionParameter Name="UserID" SessionField="UserID" Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>

让我们知道有这方面的其他问题。

let us know any other concerns on this..

这篇关于我怎么可以访问.aspx文件.aspx.cs文件的字符串变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆