本文介绍了如何使用网格编辑数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<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
我收到错误
对象引用未设置为一个对象的实例。
plz help
i'm getting error
Object reference not set to an instance of an object.
推荐答案
这篇关于如何使用网格编辑数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!