通过查询字符串检索多个ID [英] retrieve multiple id through query string

查看:150
本文介绍了通过查询字符串检索多个ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想从查询字符串中检索值


我在这里传递两个值

Hi

I want to retrieve value from querystring


I pass Two value here

<asp:TemplateField HeaderText="View">
                          <ItemTemplate>
                              <asp:LinkButton runat="server" ID="View_Detail" CommandArgument='<%#Eval("Employee_Id")+","+ Eval("Department_Id") %>'  CommandName="View" OnClick="View_Detail_Click">View Detail</asp:LinkButton>
                          </ItemTemplate>
                      </asp:TemplateField>


在aspx.cs文件中


In aspx.cs file

LinkButton View_Detail = (LinkButton)sender;

  string[] Id = View_Detail.CommandArgument.ToString().Split(new char[] {','});

  string Employee_Id = Id[0];
  string Department_Id = Id[1];
  string aa = Employee_Id + "" + Department_Id;
  Response.Redirect("~/User/HR/Delete_Assign_Department.aspx?E_ID=" + Employee_Id +"" +Department_Id );




我想在一个对象中检索Employee_Id并在另一个对象中检索部门ID

在另一页上




I want to retrive Employee_Id in one object and Department Id in another object

On another Page

string vc = Request.QueryString["E_Id"];
      Label1.Text = Convert.ToString(vc);



我如何只检索label1中的employee_id和另一个标签上的department_Id



How i retrive only employee_id in label1, and department_Id on another label

推荐答案



您可以通过附加其名称和由&字符分隔的值来指定多个查询字符串值.

在您的情况下,这看起来像:
Hi,

you can specify multiple querystring values, by appending their names and value seperated by an ampersand character.

In your scenario, this would look like:
Response.Redirect("~/User/HR/Delete_Assign_Department.aspx?E_ID=" + Employee_Id +"&D_ID=" +Department_Id );



并在Delete_Assign_Department.aspx页上检索这些值:



And to retrieve these values on Your Delete_Assign_Department.aspx page:

string EmployeeId = Request.QueryString["E_ID"];
string DepartmentId = Request.QueryString["D_ID"];



...希望对您有所帮助.



... hope it helps.


对于查询字符串中的第二个值,我们必须使用&",使用此代码,

For second value in querystring we have to use ''&'', Use this code,

Response.Redirect("~/User/HR/Delete_Assign_Department.aspx?E_ID=" + Employee_Id +"&Dept_ID=" +Department_Id );




预先感谢.




Thanks in advance.


使用两个查询字符串:

Use two query strings:

Response.Redirect("~/User/HR/Delete_Assign_Department.aspx?E_ID=" + Employee_Id +"&D_ID=" +Department_Id 



...



...

string eId = Request.QueryString["E_Id"];
string dId= Request.QueryString["D_Id"];


这篇关于通过查询字符串检索多个ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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