Click here to Skip to main content
15,911,327 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
<InlineFormModeTemplate>
                                  <div style="font-family: Tahoma; font-size: 12px;">
                                      Edit the values
                                      <br />
                                      <br />
                                      <table>
                                          <tr>
                                              <td>
                                                  Customer ID:
                                              </td>
                                              <td>
                                                  <%--<asp:TextBox ID="CustomerIDTB" runat="server" Enabled="<%#Container.CurrentRecord is GridRecord ? false : true%>"
                                                      Text='<%#GetFieldValue("CustomerID", Container)%>'>
                                                      </asp:TextBox>--%>
                                              </td>
                                          </tr>
                                          <tr>
                                          </tr>
                                          <tr>
                                              <td>
                                                  Contact Name:
                                              </td>
                                              <td>
                                                  <asp:TextBox ID="ContNameTB" runat="server" Text='<%#GetFieldValue("ContactName", Container)%>'>
                                                      </asp:TextBox>
                                              </td>
                                              <td>
                                                  Company Name:
                                              </td>
                                              <td>
                                                  <asp:TextBox ID="CompNameTB" runat="server" Text='<%#GetFieldValue("CompanyName", Container)%>'>
                                                      </asp:TextBox>
                                              </td>
                                          </tr>
                                          <tr>
                                              <td>
                                                  City:
                                              </td>
                                              <td>
                                                  <asp:TextBox ID="CityTB" runat="server" Text='<%#GetFieldValue("City", Container)%>'>
                                                      </asp:TextBox>
                                              </td>
                                              <td>
                                                  Country:
                                              </td>
                                              <td>
                                                  <asp:TextBox ID="CountryTB" runat="server" Text='<%#GetFieldValue("Country", Container)%>'>
                                                      </asp:TextBox>
                                              </td>
                                          </tr>
                                      </table>
                                      <br />
                                  </div>
                              </InlineFormModeTemplate>







vb ---------------

VB
Protected Function GetFieldValue(ByVal fieldName As String, ByVal container As GridFormEditCell) As String
       Dim editRecord As Record = container.CurrentRecord
       Return editRecord.GetValue(fieldName).ToString()
   End Function

   Public Sub GridGroupingControl1_BarButtonItemClicked(ByVal source As Object, ByVal e As Syncfusion.Web.UI.WebControls.Grid.Grouping.ButtonBarItemClickEventArgs)
       If Me.GridGroupingControl1.TableDescriptor.FormEditMode <> TableEditMode.UseTemplateForm AndAlso Me.GridGroupingControl1.TableDescriptor.FormEditMode <> TableEditMode.UseInlineTemplateForm Then
           Return
       End If

       If e.ButtonBarItem.ButtonBarItemType = ButtonBarItemType.Save Then
           Dim curRecord As Record = Me.GridGroupingControl1.FormEditCell.CurrentRecord

           Dim tb As TextBox = TryCast(Me.GridGroupingControl1.FormEditCell.FindControl("CustomerIDTB"), TextBox)
           ' If editing a current record, this will be disabled and the value will not be available.
           ' But this will be enabled when editing a new record, then lets go ahead and process it.
           If tb.Enabled Then
               curRecord.SetValue("CustomerID", tb.Text)
           End If

           tb = TryCast(Me.GridGroupingControl1.FormEditCell.FindControl("ContNameTB"), TextBox)
           curRecord.SetValue("ContactName", tb.Text)

           tb = TryCast(Me.GridGroupingControl1.FormEditCell.FindControl("CompNameTB"), TextBox)
           curRecord.SetValue("CompanyName", tb.Text)

           tb = TryCast(Me.GridGroupingControl1.FormEditCell.FindControl("CityTB"), TextBox)
           curRecord.SetValue("City", tb.Text)

           tb = TryCast(Me.GridGroupingControl1.FormEditCell.FindControl("CountryTB"), TextBox)
           curRecord.SetValue("Country", tb.Text)

           Me.GridGroupingControl1.Table.EndEdit()
           e.Handled = True
       End If

   End Sub




plz help
i'm getting error
Object reference not set to an instance of an object.
Posted
Comments
On which line?
[no name] 7-Jun-14 8:42am    
And you are getting that error for the exact same reason everyone else gets that error. You need to debug your code and find it.

1 solution

Hello Neeraj, The error - "Object reference not set to an instance of an object" is a very common error which is generated whenever we try to access any property of a null (or nothing) object.

In other words, we get this error if we try to set/get any property of an object which is not instantiated or created.

As Wes Aday[^] suggested, you have to debug your code to identify where the issue is. There is no other way around and no one can solve this but yourself.

Please let me know in case you have any further query.

- DD
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900