Wednesday, March 28, 2012

How to make table columns invisible

Hope this is the correct forum for this question. I have set up membership and roles, and have a login function. I am using a grid view and a form view to show some information that is unique to each user. In particular, I want the grid view to show the user’s client list (client first name, last name and email), and the form view to allow input by the user of client names and emails.

I have set up the grid view and connected it to a table in my data base. This is a table that includes UserName (which is also in the aspnet_Users table), Client ID (which gets set automatically by the program), clientFirstName, ClientLastname, and ClientEmail. I have a select statement of:

SELECT * FROM [Clients] WHERE ([UserName] = @.UserName)

I have checked off “Generate Insert, Update, and Delete Statements” and optimistic concurrency.

In the grid view, I’ve enabled editing and deleting in the menu task bar, and I’ve edited the columns to make ClientID and UserName “false” for the visible property (I don’t want them to show up when the user is viewing the web page).

But the problem is, when I run the application, when I try to edit a line and hit update, it won’t take the change. This does not happen if I set the UserName visible property to “true” (and so have UserName show up).

For the form view, I similarly want to have UserName and ClientID be invisible to the user.

I'm using Visual Studio 2005 Pro, and SQL Developer Edition.

Any tips on how I might do this would be appreciated! Thanks.

Tom,

You want to post this to asp.net forum. Basically, if you just bind your data resultset to a gridview, all columns will show up. To suppress the column, you need to modify the grid's column property or don't ask for the column in your sql query.|||

OJ,

Thanks much for your reply. I'll post on asp.net. It's strange, I tried to suppress the UserName column (through using "false" for the visible property), but when I do that I'm not able to edit entries when I run the application. And if I don't ask for the UserName column with the sql query, I run into the same problem. I tried using "UserId" instead of UserName in the query, but when I ran the app I got an error message that it's not part of the profile common class. I'll keep trying, thanks again.

Tom

|||Tom,

It's worth checking out info here. There are lots of info and examples for you to pick up.
http://www.asp.net/QuickStart/aspnet/doc/ctrlref/data/gridview.aspx

g'luck.|||Great, thanks OJ! I'll delve into that and see what I can come up with.

No comments:

Post a Comment