I have a datagrid with textboxes on it that are bound. Displaying the data pulled from the db works. But when a user updates a textbox I am unable to extract that data. I have tried a few options I have found involving using CType. Below is part of the code )(let me know if you need more as I a newbie at .net development). Thanks for your help.

<form name="form1">
    <div align="center"><strong>Run Date</strong> 
      <input type="text" value="<%# IIf((Request.QueryString("dt") <> Nothing), Request.QueryString("dt"), FORMATDATETIME(NOW(),2)) %>" name="DT" size="10" onChange="ValidateForm();">
      <input type="submit" value="Refresh" name="ref">
    </div>
</form>

<form runat="server">
  <div align="left">
      <asp:Button ID="butt" runat="server" Text="Add Runs" OnClick="InsertRun" />     
  </div>
  <asp:DataGrid AllowPaging="false" 
  AllowSorting="false" 
  AutoGenerateColumns="false" 
  CellPadding="3" 
  CellSpacing="0" 
  DataSource="<%# DataSet1.DefaultView %>" id="DataGrid1" 
  runat="server" 
  ShowFooter="false" 
  ShowHeader="true" OnItemCreated="colorrow" 
>
    <HeaderStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
    <ItemStyle BackColor="#F2F2F2" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" HorizontalAlign="Center" />
    <AlternatingItemStyle BackColor="#E5E5E5" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" HorizontalAlign="Center" />
    <FooterStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
    <PagerStyle BackColor="white" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
    <Columns>
    <asp:BoundColumn DataField="TRUNC(GBH.DUE_DATE)" 
        HeaderText="Batch Date" 
        ReadOnly="true" 
        Visible="True"/>    
        <asp:TemplateColumn HeaderText="Run Num" 
        Visible="True" ItemStyle-Wrap="false">
      <ItemTemplate>
         <asp:TextBox ID="runNumTxt" runat="server" Text=<%# DataSet1.FieldValue("RUNNUM", Container) %> Width="25"/> 
         <asp:CompareValidator ControlToValidate="runNumTxt" Display="Dynamic" ErrorMessage="* Numbers Only" ID="runNumTxt_val" Operator="DataTypeCheck" runat="server" Type="Integer" />
         <asp:RequiredFieldValidator ControlToValidate="runNumTxt" Display="Dynamic" ErrorMessage="* Required" ID="runNumTxt_val_req" runat="server" />
         </ItemTemplate>
    </asp:TemplateColumn>
        <asp:TemplateColumn HeaderText="Run Notes" 
        Visible="True" ItemStyle-Wrap="false">
      <ItemTemplate>
         <asp:TextBox ID="runNotesTxt" runat="server" Text=<%# DataSet1.FieldValue("RUNNOTES", Container) %> Width="75"/> 
         </ItemTemplate>
    </asp:TemplateColumn>
    <asp:BoundColumn DataField="RUNNUM" 
        HeaderText="Run Num" 
        ReadOnly="FALSE" 
        Visible="FALSE"/>    
    <asp:BoundColumn DataField="RUNNOTES" 
        HeaderText="Run Notes" 
        ReadOnly="FALSE" 
        Visible="false"/>    
<asp:TemplateColumn HeaderText="Run Status" 
        Visible="True">
      <ItemTemplate><a href="javascript:var w=openCenteredWindow('showStatus.aspx?batch=<%# trim(DataSet1.FieldValue("BATCH_NO", Container)) %>&plant=<%# trim(DataSet1.FieldValue("PLANT_CODE", Container)) %>&date=<%# trim(DataSet1.FieldValue("TRUNC(GBH.DUE_DATE)", Container)) %>',450,900,'','scrollbars = 1')"><asp:Label ID="run_status_label" runat="server" Text='<%# trim(DataSet1.FieldValue("STATUS", Container)) %>'></asp:Label></a></ItemTemplate>
    </asp:TemplateColumn>
</Columns>
  </asp:DataGrid>
</form>
</body>

Here is where I try to extract the data (there are a couple options (runNotes and runNum):

Dim aa As TextBox = CType(Me.DataGrid1.Items(i).FindControl("runNotesTxt"), TextBox)
                runNotes = aa.Text
                Dim bb As TextBox = CType(Me.DataGrid1.Items(i).FindControl("runNumTxt"), TextBox)
                runNum = bb.Text
                
                runNum = CType(Me.DataGrid1.Items(i).Cells(3).FindControl("runNumTxt"), TextBox).Text

Hello.I want to know how to use this website.I am IT 2nd year student in some university.Please let me know to use it.I know it is good website becouse I registered by concerning it.

We ended up writing the app in APEX. How do I close this thread but not mark as "solved"?

This article has been dead for over six months. Start a new discussion instead.