-
Jun 28th, 2007, 06:47 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] How can we change the value of a BoundField of Gridview
Hi all,
How can we change the value of a BoundField of Gridview like I have password field in table user_Information and I am storing password in encrypted form. My problem is that when I use following format, the Password field show those password in Encrypted form(i.e. stored in table) but I want to show them in decrypted form.
I don't know is it possible or not, if yes please let me know.thanks in advance
Code:
<asp:GridView ID="GVUser" runat="server" Width="976px" AutoGenerateColumns="False" CellPadding="1" ForeColor="#333333" AllowPaging="True" AllowSorting="True" CellSpacing="1" Font-Names="Arial" Font-Size="9pt" HorizontalAlign="Left" ToolTip='"Rack Master"' OnPageIndexChanging="GVUser_PageIndexChanging" OnSelectedIndexChanging="GVUser_SelectedIndexChanging" OnSorting="GVUser_Sorting" DataKeyNames="User_ID" DataSourceID="AccessDataSource1" >
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundField DataField="User_ID" HeaderText="ID" ReadOnly="True" SortExpression="User_ID" />
<asp:BoundField DataField="User_Name" HeaderText="Name" SortExpression="User_Name" />
<asp:BoundField DataField="Designation" HeaderText="Designation" SortExpression="Designation" />
<asp:BoundField DataField="Fathername" HeaderText="Father's Name" SortExpression="Fathername" />
<asp:BoundField DataField="DOB" HeaderText="D.O.B." SortExpression="DOB" DataFormatString="{0:dd-MMM-yyyy}" HtmlEncode="False">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:BoundField DataField="Identity_Mark" HeaderText="Identity Mark" SortExpression="Identity_Mark" />
<asp:BoundField DataField="Category" HeaderText="Category" SortExpression="Category" />
<asp:BoundField DataField="User_Password" HeaderText="Password" SortExpression="User_Password" HtmlEncode="False" />
<asp:BoundField DataField="Rights" HeaderText="Rights" SortExpression="Rights" />
<asp:BoundField DataField="bajrang" HeaderText="bajrang" SortExpression="" />
<asp:CommandField ButtonType="Image" SelectImageUrl="~/images/icon-edit.gif" ShowSelectButton="True" />
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" BorderStyle="Ridge" BorderWidth="1px" HorizontalAlign="Center" VerticalAlign="Middle" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EditRowStyle BackColor="#999999" />
</asp:GridView>
Using .NET 3.5 (VS 2008) And XP SP2
-
Jun 28th, 2007, 07:27 AM
#2
Re: How can we change the value of a BoundField of Gridview
Yes, in the RowDataBoundEvent of the GridView, grab the Text of the relevant cell and change it to your text.
How to decrypt it?? Then you need to tell us what encryption technique you are using and what code you are using??
Just a typo
Code:
//using C#
protected void myGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
If (e.Row.RowType == DataControlRowType.DataRow)
{
e.Cells[8].Text = DecryptPassword(e.Cells[8].Text);
// I assumed 8 because it seems to be the column number in your code
}
}
private string DecryptPassword(string encryptedPassword)
{
//your code here to return decrypted password
}
-
Jun 28th, 2007, 08:24 AM
#3
Thread Starter
Hyperactive Member
Re: How can we change the value of a BoundField of Gridview
Thanks Harsh.
You solved my problem. Thanks again
Using .NET 3.5 (VS 2008) And XP SP2
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|