473,804 Members | 3,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Editable data grid

6 New Member
Hi,

I am trying to implement an editable datagrid in .net 2005

This is how my grid is defined:

<asp:DataGrid runat="server" id="dgUser"
Font-Name="Verdana" Font-Size="9pt" CellPadding="5"
AlternatingItem Style-BackColor="#ddd ddd"
AutoGenerateCol umns="False" DataKeyField="U serId"
OnEditCommand=" dgUser_EditRow" >

<HeaderStyle BackColor="Navy " ForeColor="Whit e" Font-Size="13pt"
Font-Bold="True" HorizontalAlign ="Center" />

<Columns>
<asp:EditComman dColumn ButtonType="Lin kButton" HeaderText="Edi t"
EditText="Edit" UpdateText="Upd ate" CancelText="Can cel" />
<asp:BoundColum n DataField="User Id" HeaderText="Id" />

<asp:BoundColum n DataField="URol e" HeaderText="Rol e" />
<asp:BoundColum n DataField="Fnam e" HeaderText="Fir st" />
<asp:BoundColum n DataField="Mnam e" HeaderText="Mid dle" />
<asp:BoundColum n DataField="Lnam e" HeaderText="Las t" />
<asp:BoundColum n DataField="Stre etAddr" HeaderText="Str eet" />
<asp:BoundColum n DataField="AptN o" HeaderText="Apt #" />
<asp:BoundColum n DataField="City " HeaderText="Cit y" />
<asp:BoundColum n DataField="Stat e" HeaderText="Sta te" />
<asp:BoundColum n DataField="Zipc ode" HeaderText="Zip " />
<asp:BoundColum n DataField="Coun try" HeaderText="Cou ntry" />
<asp:BoundColum n DataField="Phon eNo" HeaderText="Pho ne #" />
<asp:BoundColum n DataField="Emai lId" HeaderText="Ema il" />
</Columns>

</asp:DataGrid>


And following is the event I am calling on click event of the edit button in grid



protected void dgUser_EditRow( object source, DataGridCommand EventArgs e)
{

dgUser.EditItem Index = e.Item.ItemInde x;
dgUser.DataBind ();
}


somehow its not giving me anything on pressing edit.

Do I have to put any hidden text box controls and make them visible when edit button is clicked?

Can anyone help me on this ?
Apr 20 '07 #1
1 1415
rktester
6 New Member
Thanks to all. Problem solved with gridview control ..lol

Hi,

I am trying to implement an editable datagrid in .net 2005

This is how my grid is defined:

<asp:DataGrid runat="server" id="dgUser"
Font-Name="Verdana" Font-Size="9pt" CellPadding="5"
AlternatingItem Style-BackColor="#ddd ddd"
AutoGenerateCol umns="False" DataKeyField="U serId"
OnEditCommand=" dgUser_EditRow" >

<HeaderStyle BackColor="Navy " ForeColor="Whit e" Font-Size="13pt"
Font-Bold="True" HorizontalAlign ="Center" />

<Columns>
<asp:EditComman dColumn ButtonType="Lin kButton" HeaderText="Edi t"
EditText="Edit" UpdateText="Upd ate" CancelText="Can cel" />
<asp:BoundColum n DataField="User Id" HeaderText="Id" />

<asp:BoundColum n DataField="URol e" HeaderText="Rol e" />
<asp:BoundColum n DataField="Fnam e" HeaderText="Fir st" />
<asp:BoundColum n DataField="Mnam e" HeaderText="Mid dle" />
<asp:BoundColum n DataField="Lnam e" HeaderText="Las t" />
<asp:BoundColum n DataField="Stre etAddr" HeaderText="Str eet" />
<asp:BoundColum n DataField="AptN o" HeaderText="Apt #" />
<asp:BoundColum n DataField="City " HeaderText="Cit y" />
<asp:BoundColum n DataField="Stat e" HeaderText="Sta te" />
<asp:BoundColum n DataField="Zipc ode" HeaderText="Zip " />
<asp:BoundColum n DataField="Coun try" HeaderText="Cou ntry" />
<asp:BoundColum n DataField="Phon eNo" HeaderText="Pho ne #" />
<asp:BoundColum n DataField="Emai lId" HeaderText="Ema il" />
</Columns>

</asp:DataGrid>


And following is the event I am calling on click event of the edit button in grid



protected void dgUser_EditRow( object source, DataGridCommand EventArgs e)
{

dgUser.EditItem Index = e.Item.ItemInde x;
dgUser.DataBind ();
}


somehow its not giving me anything on pressing edit.

Do I have to put any hidden text box controls and make them visible when edit button is clicked?

Can anyone help me on this ?
Apr 20 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1656
by: Venkat Chellam | last post by:
I have a webgrid in my asp.net application. Data is a grid is loaded from the database. There is edit/cancel update column to the edit the current row. When i click edit, the row becomes editable but the my column value is not shown in the editbox of the column which i need to be changed. I mean the textbox for the column should get prepopulated with the exiting column value? anyone has any idea?
1
1587
by: atif | last post by:
i m using webmatrix n i hav a prob with editable data grid. i hav set the data grid with to 100% when i load the page the data grid fits into the screen 100%. but when i clicked on add new or on update that a horizontal scroll bar used to appear n i m unable to read all the records i hav to scroll till to the end. Plz help me out Posted Via Usenet.com Premium Usenet Newsgroup Services...
8
2411
by: pmud | last post by:
Hi, I have 2 questions: 1. I have an editable data grid with 21 columns. I need to edit only 2 cloumns in this data grid. But when the grid is displayed in Edit mode, all the columns show long text boxes whichmakes the user to SCROLL a lot. I need only these 2 cloumns to be displayed in Edit mode. Is that possible & how? 2. Also, even when the data grid is not displayed in the edit mode, it
1
2886
by: JMann101 | last post by:
I am writing a ASP.NET(VB) application and am having some trouble. I have a datagrid which list users and when an admin clicks "edit" a defined column becomes visible and a dynamic listbox control is added to that column/row. When the admin clicks "update" I am unable to retrieve the values that were selected from that listbox. Basically, This is a multi-select listbox, so I need to loop to pull all selected items. This is the only...
7
2303
by: Diane | last post by:
Hi- I've been struggling with this problem and none of the fixes posted seem to help out at all. Yet, it seems like such a simple problem... I have a DataGrid, and load it up with data on page load. In my EditCommand event handler I set the editItemindex. All good. Except, the user needs to click twice to get the DataGrid to become editable. It's obvious to me (perhaps worngly) that ASP.NET is storing the data
2
1494
by: Frank | last post by:
Hello, I am developing with VS.Net 2003 on the asp 1.1 platform. I am a few days new to using a datagrid. I found a nice tutorial and had no problems using an editable datagrid with textboxes and an additional buttoncolumn where I used a delete button to delete a specific row. Once I had finished that, I trnsformed the grid tso it will display a dropdownlist indtead of a textbox. After much grappling, I pretty much have
1
2417
by: Joe Spears | last post by:
Hi I want to display a datagrid summary of a datatable. The grid will not show all the fields, but when the user selects a row, I want the other controls (text boxes) to also bind to the same row that is selected in the grid. However, the controls will bind to ALL of the fields, where the grid will only show some of them. I want to be able to edit the data using the text boxes, and then update. I also want to be able to add data using...
2
2026
by: dba56 | last post by:
In an ASP.Net 2.0 page using SQL Server 2K, I have a editable gridview that is bound to a SQLDataSource using stored procedures for its select and update queries. The grid works fine but is slow due to rebinding on postbacks when the edit, save or cancel buttons are clicked. So I set "enablecache = True" for the SQLDataSource and it is much,much faster. Clicking on edit or cancel (when in edit mode) refreshes the grid much faster. But...
1
1285
by: kithir | last post by:
Hi, I am working with asp.net.In my webform i have an editable datagrid.I am loading data from the database.I want to enter data for the particular column of the grid.But that grid has more than 50 rows.It is very hard to scroll every time to search a particular row and enter data.So i want to filter the grid by some fields present in the grid.Is it possible to do?.Any body can help?
0
1372
by: mirin | last post by:
Hello, In a Default.aspx page, I need to display an unbound grid with the following editable columns: Name, Location, Phone, Paid, Amount Initially the grid would be empty with only the column headings visible. Based on certain conditions, the Default.aspx.cs code would fetch data
0
9584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9160
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.