Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 根据用户id的下拉列表中的数据_C#_Asp.net Web Api - Fatal编程技术网

C# 根据用户id的下拉列表中的数据

C# 根据用户id的下拉列表中的数据,c#,asp.net-web-api,C#,Asp.net Web Api,我想根据登录应用程序的用户在下拉列表中显示数据 下面是MasterT.aspx.cs的代码 MasterT.aspx.cx protected void Sauser_Click(object sender, EventArgs e) { try { string s = (String.Format("SELECT top 1 user_id, Name,UserName, Password, Mo

我想根据登录应用程序的用户在下拉列表中显示数据

下面是MasterT.aspx.cs的代码 MasterT.aspx.cx

protected void Sauser_Click(object sender, EventArgs e)
        {
            try
            {
                string s = (String.Format("SELECT top 1 user_id, Name,UserName, Password, Mobile, Role_id FROM Users where UserName='{0}' and Password='{1}'", LoginT.Text, PassT.Text));

                if (r.GetTable(s).Rows.Count == 0)
                {
                    string v = " you must first log in or register before accessing this page";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('" + v + "');</script>", false);

                }
                else
                {
                    Session["user_id"] = r.GetTable(s).Rows[0]["user_id"]; **<----- I want to have this user_id.**

                    //  Response.Redirect("MasterDataEntry.aspx");
                    string v = " Welcome "+" "+ r.GetTable(s).Rows[0]["Name"]; ;
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('" + v + "');</script>", false);

                }
            }
protectedvoid Sauser\u单击(对象发送方,事件参数e)
{
尝试
{
string s=(string.Format(“从UserName='{0}'和Password='{1}'、LoginT.Text、PassT.Text的用户中选择前1个用户_id、名称、用户名、密码、手机、角色_id”);
if(r.GetTable.Rows.Count==0)
{
string v=“访问此页面前必须先登录或注册”;
RegisterStartupScript(this,typeof(Page),“Alert”,“Alert(“+v+”);”,false);
}
其他的
{
会话[“用户id”]=r.GetTable。行[0][“用户id”];****
  <asp:DropDownList ID="dbGovEntities" CssClass="form-control" runat="server" Width="20%"
                    ForeColor="Gray" Font-Size="12pt" Font-Bold="True" Style="text-align: center;"
                    Font-Names="arial" DataSourceID="SqlDataSource2" 
          DataTextField="Name" DataValueField="Id" AutoPostBack="True">
                </asp:DropDownList>

               <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
          ConnectionString="<%$ ConnectionStrings:DataEntryConnectionString %>" 
          SelectCommand="SELECT [Id], [Name] FROM [GovEntities] where user_id='@user_id'">   **<----- HERE**             
      </asp:SqlDataSource>