I am having a problem getting the value of a field on a databound grid.
Here is the situation:
I have a Formview, that contains a Datagrid, that has a databound control. I need to be able to get the value of that column so I can determine whether to do an insert or an update to a table.
Here is the definition of the Formview:
<asp:FormView ID="FormView1" runat="server" DataSourceID="odsHeader" DefaultMode="Edit"
Width="100%" DataKeyNames="SUBMITTAL_ID">
Here is the definition of the Grid:
<rad:RadGrid ID="rgContactsDisplay" runat="server" AutoGenerateColumns="False" Skin="ABL_Std" GridLines="Both"
DataSourceID="odsContacts" AllowMultiRowSelection="true" Height="170px">
<MasterTableView>
<Columns>
<rad:GridTemplateColumn UniqueName="grdCheckbox">
<ItemTemplate>
<asp:CheckBox ID= "chkContacts" runat="server" />
</rad:GridTemplateColumn> </ItemTemplate>
<rad:GridBoundColumn DataField="COMPANY_TYPE" UniqueName="company_Type" Visible="True" HeaderText="Company Type"
<HeaderStyle Width="130px" />
<ItemStyle Width="140px" />
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="COMPANY" HeaderText="Company" UniqueName="company" Visible="True"
<HeaderStyle Width="140px" />
<ItemStyle Width="140px" />
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="COMPANY_CONTACT_DATA" HeaderText="Contact" UniqueName="company_contact_data" Visible="True">
<HeaderStyle Width="130px" />
<ItemStyle Width="140px" />
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="CONTACTS_SOURCE" UniqueName="contacts_source" Visible="False" />
<rad:GridBoundColumn DataField="DOCUMENT_COMPANY_ID" UniqueName="document_company_id" Visible="False" />
</Columns>
Here is what I have so far:
Dim grdContacts As RadGrid = CType(FormView1.FindControl("rgContactsDisplay"), RadGrid) //THIS LINE DOES GIVE ME A GRID OBJ
Dim grdSource As GridDataItem = CType(grdContacts.MasterTableView.FindControl("contacts_source"), GridDataItem)
//THIS LINE COMES UP WITH GRDSOURCE = NOTHING
What I need to be able to do is check the "contacts_source" field for a value so I can determine how to process.
Obviously I'm doing something wrong with the definition for grdSource, can anyone tell me what I need to do?
Many thanks in advance.
Rich
Here is the situation:
I have a Formview, that contains a Datagrid, that has a databound control. I need to be able to get the value of that column so I can determine whether to do an insert or an update to a table.
Here is the definition of the Formview:
<asp:FormView ID="FormView1" runat="server" DataSourceID="odsHeader" DefaultMode="Edit"
Width="100%" DataKeyNames="SUBMITTAL_ID">
Here is the definition of the Grid:
<rad:RadGrid ID="rgContactsDisplay" runat="server" AutoGenerateColumns="False" Skin="ABL_Std" GridLines="Both"
DataSourceID="odsContacts" AllowMultiRowSelection="true" Height="170px">
<MasterTableView>
<Columns>
<rad:GridTemplateColumn UniqueName="grdCheckbox">
<ItemTemplate>
<asp:CheckBox ID= "chkContacts" runat="server" />
</rad:GridTemplateColumn> </ItemTemplate>
<rad:GridBoundColumn DataField="COMPANY_TYPE" UniqueName="company_Type" Visible="True" HeaderText="Company Type"
<HeaderStyle Width="130px" />
<ItemStyle Width="140px" />
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="COMPANY" HeaderText="Company" UniqueName="company" Visible="True"
<HeaderStyle Width="140px" />
<ItemStyle Width="140px" />
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="COMPANY_CONTACT_DATA" HeaderText="Contact" UniqueName="company_contact_data" Visible="True">
<HeaderStyle Width="130px" />
<ItemStyle Width="140px" />
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="CONTACTS_SOURCE" UniqueName="contacts_source" Visible="False" />
<rad:GridBoundColumn DataField="DOCUMENT_COMPANY_ID" UniqueName="document_company_id" Visible="False" />
</Columns>
Here is what I have so far:
Dim grdContacts As RadGrid = CType(FormView1.FindControl("rgContactsDisplay"), RadGrid) //THIS LINE DOES GIVE ME A GRID OBJ
Dim grdSource As GridDataItem = CType(grdContacts.MasterTableView.FindControl("contacts_source"), GridDataItem)
//THIS LINE COMES UP WITH GRDSOURCE = NOTHING
What I need to be able to do is check the "contacts_source" field for a value so I can determine how to process.
Obviously I'm doing something wrong with the definition for grdSource, can anyone tell me what I need to do?
Many thanks in advance.
Rich