将列表绑定到 asp.net gridview
我将一个列表绑定到一个显示不同配置文件的 asp.net gridview 控件(具有名称、密码、描述、日期等属性),
现在的问题在于任何人都可以访问该页面,都可以查看所有配置文件,但我不想要用于查看任何配置文件的“密码” 您可能需要它的代码:
Array k1 = yourlist1.ToArray();
business.clsprofiles obj = new business.clsprofiles();
List<business.clsprofilesprp> objprp = new List<business.clsprofilesprp>();
for (Int32 i = 0; i < k1.Length; i++)
{
Int32 z = Convert.ToInt32(k1.GetValue(i));
objprp.AddRange(obj.fnd_profiles(z));
}
GridView2.DataSource = objprp;
GridView2.DataBind();
con.Close();
I am binding a list to an asp.net gridview control which displays different profiles(having attributes such as name, password,description,date etc.)
now the problem lies anyone can visiting the page is able to view all profiles but I want no one to view the "PASSWORD" of any of the profiles
You may need the code for it:
Array k1 = yourlist1.ToArray();
business.clsprofiles obj = new business.clsprofiles();
List<business.clsprofilesprp> objprp = new List<business.clsprofilesprp>();
for (Int32 i = 0; i < k1.Length; i++)
{
Int32 z = Convert.ToInt32(k1.GetValue(i));
objprp.AddRange(obj.fnd_profiles(z));
}
GridView2.DataSource = objprp;
GridView2.DataBind();
con.Close();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能只需要隐藏 gridview 列:
...用列的索引替换 0。然而,这是一种相当随意的处理问题的方法,因为对底层类的更改可能会暴露密码列。更好的方法是:
You probably just need to hide the gridview column:
...replacing 0 with the index of the column. This is a fairly haphazard way of treating the problem however, as a change to the underlying class may expose the password column. A better approach would entail: