Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8788387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:07:58+00:00 2026-06-13T22:07:58+00:00

I have a working GridView in an ASP.Net webapp which tracks DNS records I

  • 0

I have a working GridView in an ASP.Net webapp which tracks DNS records I have requested. It’s defined as follows:

<asp:GridView ID="gvExistingEntries" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="DNSId" DataSourceID="dsDNS" Width="100%" 
    BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" 
    CellPadding="4" ForeColor="Black" GridLines="Vertical" AllowSorting="True" ShowFooter="true">
    <AlternatingRowStyle BackColor="White" />
    <Columns>
        <asp:BoundField DataField="DNSId" Visible="false" ReadOnly="true" />
        <asp:BoundField DataField="DNSName" HeaderText="DNS Name" SortExpression="DNSName" />
        <asp:BoundField DataField="IPAddress" HeaderText="IP Address" ReadOnly="True" SortExpression="IPAddress" />
        <asp:BoundField DataField="RecordType" HeaderText="Record Type" SortExpression="RecordType" />
        <asp:BoundField DataField="RequestTicket" HeaderText="Request Ticket" SortExpression="RequestTicket" />
        <asp:BoundField DataField="LastUpdateBy" HeaderText="Updated By" ReadOnly="True" SortExpression="LastUpdateBy" />

        <asp:TemplateField ShowHeader="false" ItemStyle-HorizontalAlign="Center">
            <ItemTemplate>
                <asp:LinkButton ID="updateButton" runat="server" CommandName="Edit" Text="Update" />
                <asp:LinkButton ID="deleteButton" runat="server" CommandName="Delete" Text="Delete" onClientClick="return confirm('Are you sure you want to delete this entry?');" />
            </ItemTemplate>

            <EditItemTemplate>
                <asp:LinkButton ID="saveUpdate" runat="server" CommandName="Update" Text="Save" onClientClick="return confirm('Are you sure you want to save these changes?');" />
                <asp:LinkButton ID="cancelUpdate" runat="server" CommandName="Cancel" Text="Cancel" />
            </EditItemTemplate>
        </asp:TemplateField>
    </Columns>
    <FooterStyle BackColor="#CCCC99" />
    <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
    <RowStyle BackColor="#F7F7DE" />
    <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
    <SortedAscendingCellStyle BackColor="#FBFBF2" />
    <SortedAscendingHeaderStyle BackColor="#848384" />
    <SortedDescendingCellStyle BackColor="#EAEAD3" />
    <SortedDescendingHeaderStyle BackColor="#575357" />
</asp:GridView>

The datasource is defined as follows:

<asp:SqlDataSource ID="dsDNS" runat="server" 
    ConnectionString="<%$ ConnectionStrings:DNSMonConnectionString %>" 
    SelectCommand="SELECT [DNSId], [DNSName], [RecordType], [StartValidityDate], [EndValidityDate], [IPAddress], [LastUpdate], [RequestTicket], (select [FirstName] + ' ' + [LastName] + ' (' + [Login] + ')' FROM [User] where [User].[UserID] = [DomainName].[LastUpdateBy]) AS [LastUpdateBy] FROM [DomainName] ORDER BY [DNSName]"

    UpdateCommandType="StoredProcedure"
    UpdateCommand="sp_update_DNSEntry" OnUpdating
    DeleteCommandType="StoredProcedure"
    DeleteCommand="sp_drop_DNSEntry">
    <DeleteParameters>
        <asp:Parameter Name="DNSId" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="DNSId" />
        <asp:Parameter Name="DNSName" />
        <asp:Parameter Name="RecordType" />
        <asp:Parameter Name="IPAddress" />
        <asp:Parameter Name="RequestTicket" />
    </UpdateParameters>
</asp:SqlDataSource>

Whenever the user uses the update feature this works and saves it to the database, but I want the code to resolve the IP address before it saves it. I have the method ready to go for this, but I do not know how to incorporate that into the code.

I’d rather avoid having the code on the database if possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:07:59+00:00Added an answer on June 13, 2026 at 10:07 pm

    You can update the IP address before the update by using the OnUpdating event.

    <asp:SqlDataSource OnUpdating="OnSqlUpdating"
        ... etc />
    

    In the handler code, get the Command property from SqlDataSourceCommandEventArgs, and update the appropriate parameter.

    private void OnSqlUpdating(Object source, SqlDataSourceCommandEventArgs e) 
    {
        DbCommand command = e.Command;
        command.Parameters["IPAddress"] = Request.UserHostAddress;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with asp.net 2.0 project. I have a gridview in one of
I am working on an ASP.Net website and have a GridView displaying some data,in
I have an ASP.NET GridView which is populated from a SQL Server database. This
i have a gridview i am working on VS2008 ASP.Net forms Currently, my update
I am working on Gridview in ASP.NET(C#) and have cells that need to have
i have a asp.net webpage with a GridView <asp:GridView ID=grid_view runat=server AllowPaging=True AutoGenerateColumns=False BackColor=White
Im working on asp.net with c#. I have a gridview with templatefield columns, data
I am working on an asp .net project. I have a gridview and on
I am using asp.net and I'm working with a gridview. I have one of
i am working on a Gridview on ASP .Net. I have a table in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.