如何将.aspx.cs中的值传递给aspx页面 [英] How to pass a value from .aspx.cs to aspx page

查看:110
本文介绍了如何将.aspx.cs中的值传递给aspx页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是初学者,所以我想知道如何将.aspx.cs页面的值传递给.aspx页面



原因是我想要在gridview中显示主键列。

i我不知道数据库和表我通过下拉列表选择数据库和表,所以我想将主键列传递给

 Eval( 此处

。我通过查询确定了主键列,所以请告诉我如何将它传递给aspx页面....

解决方案

您可以使用隐藏字段。设定值是你的cs代码。



例如







您可以在cs文件中访问它

Request.Form [hiddenfield1];


在您的cs页面中创建一个属性在该eval标记中绑定该属性。



现在将列名设置为该属性。



属性应该是一个字符串。



[更新]



每当你获取查询别名时所有主键都归档作为ID



现在

 Eval(  ID


i am beginner in this so i want to know how to pass a value from .aspx.cs page to .aspx page

the reason is i want to display the primary key column in the gridview .
i don''t know the database and table i am selecting the database and table through dropdownlist so i want to pass the primary key column to the

Eval("here")

. i am determined primary key column through query so please tell me how can i pass that to aspx page this please....

解决方案

You can use hidden field. Set value is your cs code .

e.g



You can access it in cs file as
Request.Form["hiddenfield1"];


Create a property in you cs page and bind that property in that eval tag.

Now set the column name to that property.

The property should be a string.

[Update]

Whenever you fetch query alias all primary key filed as ID

now

Eval("ID")


这篇关于如何将.aspx.cs中的值传递给aspx页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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