开发者

Binding a list to an asp.net gridview

开发者 https://www.devze.com 2023-02-05 17:32 出处:网络
I am binding a list to an asp.net gridview control which displays different profiles(having attributes such as name, password,description,date etc.)

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();


You probably just need to hide the gridview column:

GridView2.Columns[0].Visible = false;

...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:

  1. Not storing the passwords in plain text at all.
  2. Not pulling the passwords into the business object in the first place if you don't need them.
  3. Inheriting the underlying business object class and changing the access to the password column.
  4. Manually specifying your columns rather than using AutoGenerateColumns
0

精彩评论

暂无评论...
验证码 换一张
取 消