Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(2.0) GridView and BLL ?

Status
Not open for further replies.

TipGiver

Programmer
Sep 1, 2005
1,863
In my previous thread thread855-1349928 ca8msm helped me to accomplish a part.

This now is quite similar. I can get the fields from the db sane way.. have the datasource auto-generated as i drag and drop the table from the server explorer. Some fields are encrypted. I need to show them de-crypted.

I converted the bound fields into templates, and in the ItemTemplate there is a label (in edit template a textbox). Can this be done directly in xml somehow like: text=MyEncyptionClass.Decrypt('<%# Bind("EncryptedField") %>') ?

Or this is BLL and I need to bind a class (object) ?

Thanks
 
You can use the same technique as I suggested in thread855-1350288 although you'll have to use the RowDataBound event as you are using a GridView.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Obvioulsy i will use the e.Row.WhatNow ? The DataItem ?

Sorry to ask those silly questions, but this is the first time i use asp.net for a real project and with the use of the gridview
 
To access a Label control, you will have to use the FindControl method. You can use "e.Row.FindControl" to find a control in the row or "e.Row.Cells(0).FindControl" to find a control in a particular cell.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
So this : <asp:BoundField DataField="UserID" ... > should be converted into a template (label for example) ?

Thanks so far !
 
So this : <asp:BoundField DataField="UserID" ... > should be converted into a template (label for example) ?
I thought that is what you had already done:
I converted the bound fields into templates, and in the ItemTemplate there is a label

You don't have to convert each type of column to a template column, but if you need to manipulate the data and/or the output, I find it easier to do so.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Hi,

I was having experiments. That's why i asked this.
The findcontrol succeeded and i applied the decryption i needed. Thanks for that.

You said that this "template transform" is easier; Can you point me something to read and learn about the harder way ?
 
It's not so much harder, it's just that you don't have as much control as you will only get acces to the Text rather than an actual control. I think the only difference is that you will access the text via e.Row.Cells(0).Text but I'm not in a position to try this at the moment.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
I have an other question on this issue, so i dont open a new thread:
Can i join strings in the xml code? In a template label I have: Text='<%# Bind("FirstName") %>'
Can i add infront a "Name: " ? Whatever combinations i made, i get that the server tag is not well formed, and to check the quotes to match.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top