473,385 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Creating GridViews dynamically

Hi All,

I'm brand new to asp.net 2.0, and have a simple task of just creating a quick and dirty data entry form with SQL Server 2005 on the back end. I added a gridview to my form, and I can populate it dynamically by choosing from a dropdown that I populate dynamically from the database sys.tables table.

When I choose a table from my dropdown, poof, the gridview is beautifully loaded with all the columns and rows, and the edit and delete buttons on the left. Now I want to edit a row (and omg, eventually ADD a row). From what I've seen, you need to have an UpdateCommand something like "Update <table> Set field1 = @field1, field2 = @field2, ... Where keyfield1 = @keyfield1 and keyfield2 = @keyfield2..."

I can find all the fields and key fields through SQL, but when I click Edit on the grid and choose Update, I get an error that no Update Command exists. Obviously it doesn't know what these @ fields are, and equally obviously I don't know how to provide them.

I know I'm not doing this the MS way, of creating static sqlDataSources, but I don't want 20 gridviews on my form, one for each table, and have to constantly add new ones and change old ones. Is there a way to create the UpdateCommand dynamically, or am I all wet on this?

This reminds me of the old currency manager and the auto-generated Insert, Update, Select commands. They were great for the simplest uses, but do anything meaningful and they were impossible to use. I had a friend lose 10's of thousands of dollars, and the lawsuit, trying to create a commercial application using the currency manager. Is this the same MS trap?

TIA!
Larry
Jun 6 '07 #1
0 1545

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

Similar topics

2
by: Patrick | last post by:
I want to define a set of web-form templates in XML and render the equivalent web-form with ASP.NET, then process any input server controls on the form. Reading the XML file from Page_load is...
6
by: Tex | last post by:
I am writting a survey system web application. I am using ASP.Net 2, C# and MS SQL 2005. I am able to store surveys and questions associated to the surveys just fine. The problem I am having is...
5
by: sam | last post by:
Hi all, I am dynamically creating a table rows and inerting radio buttons which are also dynamically created. Everything works fine in Firefox as expected. But I am not able to select radio...
0
by: Nenefta | last post by:
Good afternoon everyone, I would like to create a custom GridViewand use that in the rest of my project, so all GridViews look the same. I thought it would be as easy as creating a usercontrol...
5
by: SalamElias | last post by:
I am creating several chkBoxes dynamically and assigning an event handler in the Page_load as foillows ***************************** Dim chkCatOption As CheckBox = New CheckBox chkCatOption.Text...
1
by: Carlos | last post by:
Hi all, I need to place 5 gridviews next to each other. However, during esign time, the gridviews are placed under the previous.I played with the position style of the document but it did not...
10
by: Jess | last post by:
Hello, If I create a temporary object using a dynamically created object's pointer, then when the temporary object is destroyed, will the dynamically created object be destroyed too? My guess...
4
by: mohaaron | last post by:
I can think of a lot of reasons why this might need to be done but as far as I can tell it's not possible. I've been looking for a way to add HtmlTableRows to a table using a button click for a...
8
by: stoogots2 | last post by:
I would like to reuse the code for gridview sorting for each of the several GridViews that I have on one page. I've not done this before, so I am seeking a more elegant and reusable solution than...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...

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.