Enter data into a static grid using asp.net

Currently, I am working on developing a data entry application and I have a vision for how I want it to be designed and operate. Specifically, I envision a static grid where users can click on cells to make edits. I have included an image showcasing this layout. Can anyone provide insight into how this was achieved?

https://i.sstatic.net/uYySE.png

Answer №1

This example demonstrates using a .NET GridView with row commands for adding, updating, and deleting entries.

Here is the code snippet showcasing a SQL database integration:

<asp:GridView ID="gv" RunAt="Server" DataSourceID="sqlGrid" DataKeyNames="RowID" AllowPaging="False" AutoGenerateColumns="false" EnableModelValidation="True" AutoGenerateEditButton="False" AutoGenerateDeleteButton="False" GridLines="None" BorderWidth="0">
  <Columns>
    <asp:BoundField HeaderText="Col1" DataField="Col1" SortExpression="Col1"/>
    <asp:BoundField runat="Server" HeaderText="Col2" DataField="Col2" SortExpression="Col2"/>
    <asp:CommandField HeaderText="Edit" ShowEditButton="True"/>
    <asp:CommandField HeaderText="Delete" ShowDeleteButton="True"/>
  </Columns>
</asp:GridView>

<asp:SqlDataSource ID="sqlGrid" RunAt="Server" SelectCommand="spGrid" SelectCommandType="StoredProcedure" UpdateCommand="spGridUpdate" UpdateCommandType="StoredProcedure" DeleteCommand="spGridDelete" DeleteCommandType="StoredProcedure">
  <UpdateParameters>
    <asp:Parameter Name="Col1" Type="String" />
    <asp:Parameter Name="Col2" Type="String" />
    <asp:Parameter Name="RowID" Type="Int32" DefaultValue="0" />
  </UpdateParameters>
</asp:SqlDataSource>

To allow direct input in the grid, utilize TemplateFields to insert text boxes within cells. Saving updates the cell contents in the database.


Add Empty Row

<asp:TemplateField HeaderText="Col1" SortExpression="Col1">
    <ItemTemplate>
        <asp:TexBox ID="txt1" runat="server"></asp:TexBox >
        <asp:TexBox ID="txt2" runat="server"></asp:TexBox >
    </ItemTemplate>
</asp:TemplateField>

IMPLEMENTATION STEPS

  1. Set up database, tables, and columns.
  2. Create stored procedures for database CRUD operations.
  3. Construct GridView with template fields and textboxes.
  4. Fetch data into the GridView from stored procedures.
  5. Utilize sqlDataSource and row commands for updating gridview data.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I'm encountering errors from JQuery right from the start of the code

Hey there, I encountered a problem with my script: $(document).ready(function(){ alert("works"); }) I tried using a regular document.ready check but it keeps throwing 7 errors at me. Check out the screenshot of the errors here Any help or advice wo ...

What is the process of converting the string 'dd/mm/yy hh:MM:ss' into a Date format using javascript?

I successfully completed this task. var date = 'dd/mm/yy hh:MM:ss'; var dateArray = date.split(" "); var splitDate = dateArray[0].split("/"); var splitTime = dateArray[1].split(":"); var day = splitDate[0]; var month = sp ...

Choose the data from the initial entry to the second entry within the database

I am currently working on a project that requires me to retrieve dates from a database. The goal is to replace outdated dates with newer ones as they pass. Unfortunately, I am unsure how to achieve this and would greatly appreciate any assistance. It see ...

I'm struggling to grasp the concept of State in React.js

Even though I'm trying my best, I am encountering an issue with obtaining JSON from an API. The following error is being thrown: TypeError: Cannot read property 'setState' of undefined(…) const Main = React.createClass({ getInitia ...

Update D3 data, calculate the quantity of rows in an HTML table, and add animations to SVGs in the final

Attempting to update data in an HTML table using D3 has proven to be quite challenging for me. My task involves changing the data in multiple columns, adjusting the number of rows, and animating SVG elements in each row based on new data arrays. Despite tr ...

Prevent selection of any dates before the most recent 2 days on the jQuery datepicker

Is there a way to restrict the date-picker from displaying past dates, except for the last 2 dates? <link href="Content/jquery-ui-1.8.23.custom.css" rel="stylesheet" /> <script src="Scripts/jquery-1.8.1.min.js"></script> <script src=" ...

Instructions on how to insert a single parenthesis into a string using Angular or another JavaScript function

Currently, I am employing Angular JS to handle the creation of a series of SQL test scripts. A JSON file holds various test scenarios, each scenario encompassing a set of projects to be tested: $scope.tests = [ { "Date": "12/31/2017", "Project": ...

Spin the mergeometry object around its center in Three.js

I've been struggling to figure out how to rotate the object at its center. Right now, I can rotate the scene but the object moves away from the user. I've tried looking at similar questions on forums, but haven't been able to make it work. B ...

Collaboratively utilize a connection string across different web projects

I am currently working on two web projects, WebProject1 and WebProject2. Both of these projects require database connectivity, so the database logic is implemented in a C#.NET project called Common. My main concern now is that the connection string for bo ...

Is it beneficial to rotate an image before presenting it?

I am looking for a way to display a landscape image in portrait orientation within a 2-panel view without altering the original file. The challenge I am facing is that the image size is set before rotation, causing spacing issues with DOM elements. Is ther ...

Is there a more efficient approach to displaying a list of elements and sharing state in React with TypeScript?

Check out this code sample I'm attempting to display a list with multiple elements and incorporate a counter on the main element that updates every time one of the buttons is clicked. I'm uncertain if this approach is optimal, as I am transition ...

Tips for adjusting the current window location in Selenium without having to close the window

I am currently working with seleniumIDE My goal is to have a Test Case navigate to a different location depending on a condition (please note that I am using JavaScript for this purpose, and cannot use the if-then plugin at the moment). I have tried using ...

The search for 'sth' cannot be done using the 'in' operator on an undefined value

Here is the code snippet I'm working on: . . keydown: function(ev) { clearTimeout( $(this).data('timer') ); if ( 'abort' in $(this).data('xhr') ) $(this).data('xhr').abort(); // encountering an ...

Leveraging Express and Node.js: The Ultimate Approach to Invoking an External API

I'm brand new to working with Express and Node.js. I'm currently attempting to access an external API in order to populate data on a webpage. Is there a more efficient way to make this API call directly from Express itself (I know that the http m ...

PHP code for sending a file alongside displaying text on the browser using the echo command using X-SendFile

I am currently utilizing the X-SendFile Apache Module to facilitate the download of large files from our server. The downloads are functioning as expected; however, I am faced with an issue regarding outputting text to the browser when a download is initia ...

Trigger an event upon the completion of any AJAX request

Seeking to observe the onComplete event of all AJAX requests externally without being within the individual requests. Wanting to trigger an event when any or all AJAX requests finish. Is this achievable? Many thanks, Tim Edit: Only using Mootools libra ...

Nativescript encountered an issue while attempting to generate the application. The module failed to load: app/main.js

I'm currently experimenting with the sample-Groceries application, and after installing NativeScript and angular 2 on two different machines, I encountered the same error message when trying to execute: tns run android --emulator While IOS operations ...

How can you determine if a user has selected "Leave" from a JavaScript onbeforeunload dialog box?

I am currently working on an AngularJS application. Within this app, I have implemented code that prompts the user to confirm if they truly want to exit the application: window.addEventListener('beforeunload', function (e) { e.preventDefault ...

Discover a method to obtain the indexof() starting from the last character of a string

I'm wondering how to determine the number of characters after the "|" symbol in this string: "354-567-3425 | John Doe". I did some research and only came across the javascript indexOf() method. While this method is useful for finding characters before ...

The response header does not contain a valid JWT token

Here's a function I've implemented to authenticate users by creating a response header: function verifyUser(res, id) { const payload = { id } const token = jwt.sign(payload, config.JWT_KEY, { expiresIn: '24h' ...