| |

VerySource

 Forgot password?
 Register
Search
View: 656|Reply: 4

Anxious, begging for advice: How to display and update the value of a dynamically added field in the table?

[Copy link]

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-17 09:00:01
| Show all posts |Read mode
The function is like this, there is a raw data table with some fields, and then users add some fields according to their needs. The added field names are stored in a custom field table. At the same time, the original data table is modified and the corresponding columns are added.
I want to know how to view and update the values ​​of dynamically added fields in the original data table?
I beg your advice, I am grateful! This problem has troubled me for a long time.
Reply

Use magic Report

0

Threads

25

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-4-27 11:45:02
| Show all posts
Help top.
The problem is a bit troublesome, no one is coming.
The added field name is stored in a custom field table: under the datatable style.
Modify the original data table, increase the corresponding column: you can use SQL statements or stored procedures or transactions.
View and update the values ​​of dynamically added fields in the original data table: after the above steps, you can re-query and update the table.
... in my humble opinion, I look forward to the appearance of an expert.
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-27 15:00:01
| Show all posts
I want to know how to view and update the value of the dynamically added field in the original data table?
=========
Query the newly added field from the field table
This generates a select statement.

Then execute the line.
strSQL = "SELECT";

foreach (DataRow row in dt.Rows)
{
     strSQL + = row ["ColumnName"]. ToString () + ",";
}

strSQL = strSQL .SubString (0, strSQL .Length-1);

strSQL + = "FROM table"
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-27 15:30:01
| Show all posts
Of course, you can also use stored procedures

declare @strSql Nvarchar (4000)

set @strSQL = 'SELECT'

Select @strSQL = @strSQL + ColumnName + ',' from field table where condition


set @strSQL = LEFT (@ strSQL, len (@strSQL) -1)


set @strSQL = @strSQL + 'from table'

EXECUTE (@strSQL)
Reply

Use magic Report

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-7-22 09:30:01
| Show all posts
Thank you for your kind advice, I have solved this problem. With sqldatasource, the value of selectcommand and updatecommand of sqldatesource are dynamically pointed in the page_load event, and the required functions are realized.

But recently I encountered another problem: I want to determine which cells the user has selected in the table, and process other tables in the database according to the contents of the selected cells. Don't know how to implement this function? Thank you for your advice!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list