Column Type For Database-Retrieved Column : Windows Forms DataGridView Control

IT STUDENT 0 Reputation points
2023-06-01T03:47:23.7333333+00:00

Hi. My issue is that related to the 3-tier Application development using ASP.NET (.NET Framework). As an IT student, I have been tasked to code for CRUD function using 3-tier.

For the Update functionality, I am facing an issue where for the row ' string tid = ((TextBox)row.Cells[0].Controls[0]).Text; ' it gives an error and I know that it is because of the '(TextBox)' part where you are supposed to input a Column Type for DataGridView. I do not understand how to resolve the issue since that column for me is retrieved from the database (a self-incremental primary key field 'PostID') and is not a 'TextBox' field unlike the other two mentioned columns. I do not know what to change the Column Type value to since those that I read about @ https://learn.microsoft.com/en-us/dotnet/desktop/winforms/controls/column-types-in-the-windows-forms-datagridview-control?view=netframeworkdesktop-4.8 ('Column Types in the Windows Forms DataGridView Control' article) are not applicable in my case.

Pls advise if anyone knows the field type (column type) for a database-retrieved, unmodifiable column in DataGridView. (Pls refer to the code snippet below for reference) Thank you.

protected void gvPosts_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            PostsBLL pBLL = new PostsBLL();

            GridViewRow row = (GridViewRow)gvPosts.Rows[e.RowIndex];
            int id = int.Parse(gvPosts.DataKeys[e.RowIndex].Value.ToString());
            string tid = ((TextBox)row.Cells[0].Controls[0]).Text;
            string turgency = ((TextBox)row.Cells[3].Controls[0]).Text;
            string tdesc = ((TextBox)row.Cells[4].Controls[0]).Text;

            pBLL.PostUpdate(tid, turgency, tdesc);

            gvPosts.EditIndex = -1;
            bind();
        }
Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,828 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,254 questions
{count} votes