我使用的是Infragistics数据网格V11.2。网格仅显示1列,其中隐藏了10列。我需要在网格中插入一行。 RowAdding元素不支持模板。因此,当我使用此选项时,它只显示1列。我尝试在网格上方创建一个表,其中包含要添加的字段和一个用于添加调用javascript函数的按钮。当我在调试中使用它时,单击按钮后不会调用该函数。另外,我现在不知道这个函数可以触发存储过程将数据插入数据库。
这是我创建的用于添加行的表:
<table style="width: 875px; background-color:#F0F8FF; text-align:left;">
<tr>
<td colspan="4" align="left" class="style1">
<b>Add New Office:</b>
</td>
</tr>
<tr>
<td>
Address Prefix:
</td>
<td>
<asp:TextBox ID="txtAddressPrefix" runat="server" Text="" ClientIDMode="Static" />
</td>
<td>
Address:
</td>
<td>
<asp:TextBox ID="txtAddress" runat="server" Text="" ClientIDMode="Static" />
</td>
</tr>
<tr>
<td>
Address Suffix:
</td>
<td>
<asp:TextBox ID="txtAddressSuffix" runat="server" Text="" ClientIDMode="Static" />
</td>
<td>
City:
</td>
<td>
<asp:TextBox ID="txtCity" runat="server" Text="" ClientIDMode="Static" />
</td>
</tr>
<tr>
<td>
City Mailing:
</td>
<td>
<asp:TextBox ID="txtCityMailing" runat="server" Text="" ClientIDMode="Static" />
</td>
<td>
State:
</td>
<td>
<asp:TextBox ID="txtState" runat="server" Text="" ClientIDMode="Static" />
</td>
</tr>
<tr>
<td>
Zip:
</td>
<td>
<asp:TextBox ID="txtZip" runat="server" Text="" ClientIDMode="Static" />
</td>
<td>
County ID:
</td>
<td>
<asp:DropDownList ID="ddlCounty" runat="server"
DataSourceID="SqlDataSource3"
DataValueField="ID"
DataTextField="Name" ClientIDMode="Static">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Lat:
</td>
<td>
<asp:TextBox ID="txtLat" runat="server" Text="" ClientIDMode="Static" />
<asp:MaskedEditExtender ID="MaskedEditExtender3" runat="server" MaskType="Number"
TargetControlID="txtLat" Mask="99\.999999999" AcceptNegative="Left">
</asp:MaskedEditExtender>
</td>
<td>
Long:
</td>
<td>
<asp:TextBox ID="txtLong" runat="server" Text="" ClientIDMode="Static" />
<asp:MaskedEditExtender ID="MaskedEditExtender4" runat="server" MaskType="Number"
TargetControlID="txtLong" Mask="99\.999999999" AcceptNegative="Left">
</asp:MaskedEditExtender>
</td>
</tr>
<tr>
<td colspan="4" align="left">
<input type="button" onclick="addRow()" value="Add New Row" />
</td>
</tr>
</table>
这是infragistics网格和数据源:
<ig:WebHierarchicalDataGrid runat="server" height="600px" width="875px" ClientIDMode="Static"
AutoGenerateBands="False" AutoGenerateColumns="False" DataKeyFields="ID"
DataMember="SqlDataSource1_DefaultView" StyleSetName="Windows7" ID="wdgOffice"
DataSourceID="WebHierarchicalDataSource1" Key="SqlDataSource1_DefaultView"
onrowadded="wdgOffice_RowAdded" onrowadding="wdgOffice_RowAdding">
<Columns>
<ig:BoundDataField DataFieldName="ID" Key="ID" Hidden="true">
<Header Text="ID" />
<header text="ID" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="AddressPrefix" Key="AddressPrefix" Hidden="true">
<Header Text="AddressPrefix" />
<header text="AddressPrefix" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Address" Key="Address" Hidden="true">
<Header Text="Address" />
<header text="Address" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="AddressSuffix" Key="AddressSuffix" Hidden="true">
<Header Text="AddressSuffix" />
<header text="AddressSuffix" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="City" Key="City" Hidden="true">
<Header Text="City" />
<header text="City" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="CityMailing" Key="CityMailing" Hidden="true">
<Header Text="CityMailing" />
<header text="CityMailing" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="State" Key="State" Hidden="true">
<Header Text="State" />
<header text="State" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Zip" Key="Zip" Hidden="true">
<Header Text="Zip" />
<header text="Zip" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="CountyName" Key="CountyID" Hidden="true">
<Header Text="CountyID" />
<header text="CountyID" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Lat" Key="Lat" Hidden="true">
<Header Text="Lat" />
<header text="Lat" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Long" Key="Long" Hidden="true">
<Header Text="Long" />
<header text="Long" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Name" Key="Name" Width="95%">
<Header Text="Name" />
<header text="Name" />
</ig:BoundDataField>
</Columns>
</ig:WebHierarchicalDataGrid>
</ContentTemplate>
</asp:UpdatePanel>
<ig:WebHierarchicalDataSource ID="WebHierarchicalDataSource1" runat="server">
<DataViews>
<ig:DataView ID="SqlDataSource1_DefaultView" DataMember="DefaultView"
DataSourceID="SqlDataSource1" />
</DataViews>
</ig:WebHierarchicalDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CAP06 %>"
SelectCommand="phyadmGetOffices2" SelectCommandType="StoredProcedure"
InsertCommand="phyadmInsOffices" InsertCommandType="StoredProcedure">
<InsertParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="AddressPrefix" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="AddressSuffix" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="CityMailing" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="Zip" Type="String" />
<asp:ControlParameter Name="CountyID" ControlID="ddlCounty" Type="Int32" PropertyName="SelectedValue" />
<asp:Parameter Name="Lat" Type="Decimal" />
<asp:Parameter Name="Long" Type="Decimal" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:CAP06 %>"
SelectCommand="phyadmGetCounty2" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>
我还尝试通过添加:
来使用RowAdding行为<ig:RowAdding>
<AddNewRowClientEvents EnteringEditMode="WebDataGrid1_RowAdding_EnteringEditMode" />
</ig:RowAdding>
这也不起作用。它添加了一个插入行。 (带+的空白行)。当用户单击空行时,调用WebDataGrid1_RowAdding_EnteringEditMode方法。但我需要在行中添加10个字段。这不直观。
如果有人有任何其他方法可以将行插入数据库并更新网格,我将不胜感激。
感谢。
答案 0 :(得分:0)
对于有此问题的其他人...您无法在Infragistics Grid中插入隐藏的行。我所做的是在网格上方创建一个表,使用“添加”按钮插入带有隐藏元素的行数据。