Bind and Delimit a stringarray property value in web control and Update content

peter liles 556 Reputation points
2021-06-03T00:27:39.417+00:00

I would like to be able to bind and convert a stringarray value property into a list for output in web control like gridview bound to datasource like SqlDatasource and able to perform tasks like add string value,update a string value and delete string value from list and save back to database as a string array property. Can this be done without manipulate in code behind?

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,243 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,547 questions
{count} votes

6 answers

Sort by: Most helpful
  1. peter liles 556 Reputation points
    2021-06-03T17:03:13.26+00:00

    I was wondering if possible to split a comma delimiter string while bound to label and populate gridview. then proceed to perform insert/update/delete operations on row column values while maintain property as a delimited string in database.


  2. peter liles 556 Reputation points
    2021-06-03T20:33:01.547+00:00

    I tried this approach but it produced an error?
    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Category").Split(",") %>'></asp:Label>


  3. peter liles 556 Reputation points
    2021-06-05T06:45:33.97+00:00

    That returns only the first row whereas i require the whole lot.
    I tried this approach using datareader to return data.
    SELECT CATEGORYID,CATEGORY,SIZES FROM Product

    rdr = cmd.ExecuteReader()

    Do While rdr.Read
    Dim Cat As String() = (rdr.GetString(1).Split(New Char() {","c}))

    but i also require to return another column SIZES also.

    Dim SIZE As String() = (rdr.GetString(2).Split(New Char() {","c}))
    when i tried join both sets together in an arraystring they are added together on top of one another with sizes added to last index like:

    1 null large
    2 null small
    3 null small
    4 dog null
    5 cat null

    while i require a list that share same ID column value like:
    ID Category SIZES
    1 dog large
    2 dog small
    3 cat small
    4 cat tiny
    5 null big

    where columns share same ID. The null value in Category column is when no value present in column as i have in table structure.


  4. peter liles 556 Reputation points
    2021-06-07T12:39:52.483+00:00

    Them two lists i gave you now represent two product list objects except the ID value is now same numerical value i.e. 3.
    So what i would like is to combine the two Lists - List(of product) like output:

    3 dog large

    the two lists are of different length so the output should show a replacement null value for missing value in either list objects.

    3 null big
    i tried using a foreach loop but it creates a endless loop ?
    Probably require a identity column also to represent unique row as you have stated?
    once i succeed in producing this format i can insert values into a new table structure. It saves having to add manual!


  5. peter liles 556 Reputation points
    2021-06-08T12:22:56.017+00:00

    I have created new table but i now need to transfer the data from the old table which is in the form of a string separated by comma.
    That's the reason i am attempting to create two lists of values in order to insert them into new table structure. I understand there is a SQL function available to perform task of string manipulation but it is not available on my server.

    0 comments No comments