views:

127

answers:

2

I am using C#, Visual Studio 2005

I have created textbox on runtime/dynamic way and inserted/saved sql data on database but the problem is how to retrive the same data on same way for edit / update.

e.g.

col1 col2

mahesh 1000

kirti 2000

the above data stored in sql server. I don't know how to retrive the same on dynamic way by creating dynamic textbox and retrive the same.

suggest proper code please.

A: 

I'm not quite sure i follow 100% but you could have a drop down that is populated from the database, Select the item in this drop down, Enter the details in to your textboxes and have a button to activate the update.

In steps Get your data into a local list. Populate the drop down using this list.

You now still have your local list with the appropriate data.

Get the user to select an item from the drop down. Use the drop downs selected index to get the item from the list. Change the values within this item and commit to the database

I would have thought it would be far easier using the appropriate control for displaying the information such as a listview or datagrid

   List<String> objInformationList = new List<String>();
objInformationList = "Your database query function";
foreach(String objCurrentString in objInformationList){
// Create your text box
// Set your text within your textbox
// Add the text box to the screen or a table structure
}

I personally would be doing this another way

Truezplaya
am appreciate ur reply.but it's time consuming. See user enter data on specific dynamically created textboxes and saved it. and as per ur suggestion again populate data on drop down and modifying it's not well sir, i have to directly populate data on textbox which is save the time. suppose i have three sql records so textbox will be three there by binding the data. "time is Precious Sir"
mahesh
So if the database contains 3 cols lets say col 1, col 2, col 3(col 1 is your unique identifier). You then have 2 textboxes(which accept values for col 2 and col 3 as col 1 is an autoincrement) dynamically created which accept values and when you click a button they get sent to the database What you want to do now is use the dynamically created textboxes to update the data within the database?
Truezplaya
no sir,suppose I have col1 in sql database in which three records available for specific ID i want to bind this three records or rows in three textboxes dynamically/runtime. In future it may be more than three so how is do please provide necessary code.
mahesh
thx sir,am trying ur above suggested code and will get u later. if u done this by another way then please suggest me.
mahesh
i wouldn't be putting the data in to textboxes for display i would be using a listview or a gridview a control that was created to display information
Truezplaya
as above said objectinformationList = " Your database query function".so u mean to provide "select sql query" which is raise system error cannot convert type string or further. please clear
mahesh
Finally I have done it by the Sql Tables.Rows.Count with help of SqlDataAdapter and Dataset. I have bind whatever records or rows availabe in Sql tables with Dynamic Textboxes. thx for ur Help.
mahesh
A: 

Create datasource. Read the data into the datasource. Add the controls and bind the dynamic controls to that data source.

vikp
give example by coding which i have demanded sir
mahesh