locked
HELP WITH DATASOURCE AND QUERY IN ASP.NET RRS feed

  • Question

  • User1659542522 posted

    hello, I have a doubt with a query in SQL and ASP.NET.

    I have a website with a GridView and an SqlDataSource. A Custom SUb to encrypt and decrypt on the database of MS-SQL keep the encrypted data in a field (Password) according to my Sub. I need the GridView to display the data decrypted according to my custom procedure, data edit, delete and add, using my sub to encrypt and decrypt.
    If I do directly binding the GridView with the SqlDataSource data are not encrypted as need.

    Thank you for your help.

    Tuesday, November 12, 2013 9:25 AM

Answers

  • User-933407369 posted

    hi mercetokio,

    you can add the code for your grid's RowDataBound as below:

     Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound
    
            If e.Row.RowType = DataControlRowType.DataRow Then
    
               ' Dim rowView As DataRowView = CType(e.Row.DataItem, DataRowView)
               'Get the raw password here
                dim password as string = e.Row.Cells(1).Text
               ' Call ur function to encrypt it
                'e.Row.Cells(1).Text = EncryptPassword(passwor)
    
                '...
    
            End If
          End Sub

    Hope it helps you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 13, 2013 5:26 AM
  • User-1965857832 posted

    mercetokio

    I use ASP.net, Languaje Vb.net, but interpreting similar sintax jejejeje...
    Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs)
    	If e.Row.RowType.Equals(DataControlRowType.DataRow) Then
    		'Get the raw password here
    	        'Call ur function to encrypt it
    		'e.Row.Cells[1].Text = EncryptPassword(passwor);
    		Dim password As String = e.Row.Cells(1).Text
    	End If
    End Sub

    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 13, 2013 5:31 AM

All replies

  • User-1965857832 posted

    my custom procedure

    I guess its in .net, if yes u could do this

    Add handler for ur grid's RowDataBound as below

    <asp:GridView ID="GridView1" runat="server" AllowPaging="true" PageSize="3" OnRowDataBound="GridView1_RowDataBound" />

    And call ur ustom procedure to encrypt the password as below

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType.Equals(DataControlRowType.DataRow))
            {
                //Get the raw password here
                string password = e.Row.Cells[1].Text;
                // Call ur function to encrypt it
                //e.Row.Cells[1].Text = EncryptPassword(passwor);
            }
        }




    Tuesday, November 12, 2013 11:38 AM
  • User1659542522 posted

    Hi, thank for your answer.

    I Try this and comment it...

    I use ASP.net, Languaje Vb.net, but interpreting similar sintax jejejeje...

    Tuesday, November 12, 2013 1:08 PM
  • User-933407369 posted

    hi mercetokio,

    you can add the code for your grid's RowDataBound as below:

     Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound
    
            If e.Row.RowType = DataControlRowType.DataRow Then
    
               ' Dim rowView As DataRowView = CType(e.Row.DataItem, DataRowView)
               'Get the raw password here
                dim password as string = e.Row.Cells(1).Text
               ' Call ur function to encrypt it
                'e.Row.Cells(1).Text = EncryptPassword(passwor)
    
                '...
    
            End If
          End Sub

    Hope it helps you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 13, 2013 5:26 AM
  • User-1965857832 posted

    mercetokio

    I use ASP.net, Languaje Vb.net, but interpreting similar sintax jejejeje...
    Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs)
    	If e.Row.RowType.Equals(DataControlRowType.DataRow) Then
    		'Get the raw password here
    	        'Call ur function to encrypt it
    		'e.Row.Cells[1].Text = EncryptPassword(passwor);
    		Dim password As String = e.Row.Cells(1).Text
    	End If
    End Sub

    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 13, 2013 5:31 AM