Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8454337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:00:02+00:00 2026-06-10T12:00:02+00:00

I have a GridView with a bunch of DynamicFields like so; <asp:GridView ID=GridView1 runat=server

  • 0

I have a GridView with a bunch of DynamicFields like so;

<asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource">
<Columns>
<asp:DynamicField HeaderText="Date Submitted" DataField="DATE_CREATED" />
<asp:DynamicField HeaderText="Assigned To" DataField="ASSIGNED_TO" />
<asp:DynamicField HeaderText="Active Account" DataField="Active_Account" />
<asp:DynamicField HeaderText="Client ID" DataField="CLIENT_ID" />
<asp:DynamicField HeaderText="Client Type" DataField="CLIENT_Type" />
</Columns>
</asp:GridView>

<asp:EntityDataSource ID="GridDataSource" OnSelected="TotalRows" runat="server" 
EnableDelete="true">
    <WhereParameters>
        <asp:DynamicControlParameter ControlID="FilterRepeater" />
    </WhereParameters>
</asp:EntityDataSource>

Now it displays fine, the right data comes to screen but when I try to access that data using a row number I’m always finding blank cells. For example I tried the following to check every cell but to no avail;

Dim x As Integer = 0
    Dim y As Integer = 0
    While x < GridView1.Rows.Count
        While y < GridView1.Rows(x).Cells.Count
            If Not (GridView1.Rows(x).Cells(y).Text = "") Then
                MsgBox(String.Format("{0},{1},{2}", x.ToString, y.ToString, 
                      GridView1.Rows(x).Cells(y).Text))
            End If
            y = y + 1
        End While
        x = x + 1
        y = 0
    End While

No message box displayed so all the cells are empty strings. But I can clearly see they’re populated on screen! What am I doing wrong?

UPDATE

After Pilgerstorfer Franz suggestion that I look for Textbox elements I used the following code which basically looks at all the cells in the table and try’s to pull data out of them and if it’s not blank then display a msgbox (also informs me of any new controls I haven’t accounted for);

If GridView1.Rows(0).RowType = DataControlRowType.DataRow Then
    For r = 0 To GridView1.Rows.Count - 1
        For c = 0 To (GridView1.Rows(r).Cells.Count - 1)
            Dim cell = GridView1.Rows(r).Cells(c)

            For b = 0 To cell.Controls.Count - 1
                If (cell.Controls(b).GetType() Is GetType(TextBox)) Then
                    Dim td = CType(cell.Controls(b), TextBox)
                    Text = td.Text.Trim
                ElseIf (cell.Controls(b).GetType() Is GetType(LiteralControl)) Then
                    Dim td = CType(cell.Controls(b), LiteralControl)
                    Text = td.Text.Trim
                ElseIf (cell.Controls(b).GetType() Is GetType(DynamicControl)) Then
                    Dim td = CType(cell.Controls(b), DynamicControl)
                    Text = td.Table.Columns.Item(c).DisplayName()
                Else
                    MsgBox(String.Format("New Control of type: {0}", cell.Controls(b).GetType().FullName))
                End If
                If Not Text = "" Then
                    MsgBox(String.Format("{0},{1},{2}", c.ToString, b.ToString, Text))
                End If
            Next
        Next
    Next
End If

Unfortunately most cells just contained DynamicControl and since I was putting the DisplayName into Text I was just getting the column header every time. So how do I get the text value property out of a DynamicControl?

Additional Info

I’m further confused by this problem because since this is a project that I’m updating there is initial code two lines of which are;

Dim UserID = Convert.ToInt32(GridView1.DataKeys(e.RowIndex).Value)
Dim clientType As String = GridView1.DataKeys(e.RowIndex).Item(1).ToString

These successfully bring back UserID and ClientType. Now I don’t really understand DataKeys but I tried using;

Dim clientType As String = GridView1.DataKeys(e.RowIndex).Item(Num).ToString

where Num increases by one every time expecting it to bring back the rest of the row data, but I simply got an index was out of range error.

ANOTHER UPDATE!!

Here is another bit of the ASPX page but I’n not entirely certain what it does. Pilgerstorfer Franz created some code to look for the textboxes created by the dynamicControl. Now I’m wondering if this code here causes other types of controls to be used rather than Textboxes. Thoughts?

<asp:FilterRepeater ID="FilterRepeater" runat="server" Visible="false">
            <ItemTemplate>
                <h2><asp:Label ID="lblDisplay" runat="server" Text='<%#
Eval("DisplayName") %>' AssociatedControlID="DynamicFilter$DropDownList1" /></h2>
                <asp:DynamicFilter runat="server" ID="DynamicFilter" 
OnSelectedIndexChanged="OnFilterSelectedIndexChanged" />
            </ItemTemplate>
            <FooterTemplate><br /><br /></FooterTemplate>
        </asp:FilterRepeater>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:00:04+00:00Added an answer on June 10, 2026 at 12:00 pm

    Iterating through the controls never worked for me so in the end I gave up and just queried the DB again… Eh it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have GridView: <asp:GridView ID=MyGridView runat=server ShowFooter=true AutoGenerateColumns=False Visible=True> <Columns> <asp:BoundField DataField=id ItemStyle-HorizontalAlign=center/> <asp:BoundField
I have GridView and Button controls nested inside a Panel . <asp:Panel ID=PanelPopUp runat=server>
I have gridview in my asp.net 3.5 application [C#]. Which looks like this: <asp:GridView
i have gridview in my asp.net webform. i bind my database to gridview like
Well, I have GridView with editable field like 'TemplateField' with DropDownList. My code: <Columns>
I have a ASP.NET GridView that uses template columns and user controls to allow
I have a whole bunch of very narrow columns in a DevExpress GridView and
I have Gridview like this. Here is my last column Gridview code; <EditItemTemplate> <asp:TextBox
I have an asp.net GridView with a DropwDownlist control and a bunch of other
I have a GridView like this( main.xml ): <?xml version=1.0 encoding=utf-8?> <GridView xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/gridView1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.