无法编辑单元格是ASP.Net 4.0 / Visual Studio 2010中的Infragistics WebDataGrid。为什么?

时间:2012-05-24 20:57:55

标签: asp.net-4.0 infragistics webdatagrid

My Infragistics当我双击一个单元格时,WebDataGrid不会进入单元格编辑模式。它没有进入服务器模式 - 没有任何反应。只发生客户端事件,但我怀疑这些事件是必要的。下面的asp.net段有什么问题?

<infra:WebDataGrid ID="wdgProjects" runat="server" EnableAjax="true" AutoGenerateColumns="False"
                        DataSourceID="sqlProjects" DataKeyFields="ProjectID"
                        OnInitializeRow="wdgProjects_InitializeRow"
                        OnCellSelectionChanged="wdgProjects_CellSelectionChanged"
                        OnActiveCellChanged="wdgProjects_ActiveCellChanged" 
                    >
                        <Columns>
                            <infra:TemplateDataField Key="ProjectID" Header-Text="Project ID">
                                <ItemTemplate>
                                    <asp:Label ID="lblProjectID" runat="server" />
                                </ItemTemplate>
                            </infra:TemplateDataField>
                            <infra:TemplateDataField Key="ProjectName" Header-Text="Project Name">
                                <ItemTemplate>
                                    <asp:Label ID="lblProjectName" runat="server" />
                                </ItemTemplate>
                            </infra:TemplateDataField>
                            <infra:TemplateDataField Key="ReportingPeriod" Header-Text="Reporting Period">
                                <ItemTemplate>
                                    <asp:Label ID="lblReportingPeriod" runat="server" />
                                </ItemTemplate>
                            </infra:TemplateDataField>
                            <infra:TemplateDataField Key="ProjectCreator" Header-Text="Project Creator">
                                <ItemTemplate>
                                    <asp:Label ID="lblProjectCreator" runat="server" />
                                </ItemTemplate>
                            </infra:TemplateDataField>
                            <infra:TemplateDataField Key="ProjectCreation" Header-Text="Project Creation Date">
                                <ItemTemplate>
                                    <asp:Label ID="lblProjectCreation" runat="server" />
                                </ItemTemplate>
                            </infra:TemplateDataField>
                        </Columns>
                        <Behaviors>
                            <infra:Activation Enabled="true" />
                            <infra:Selection RowSelectType="Single" CellClickAction="Cell" />
                            <infra:EditingCore AutoCRUD="false" Enabled="true" BatchUpdating="false">
                                <Behaviors>
                                    <infra:CellEditing Enabled="true" EditModeActions-MouseClick="Double">
                                        <ColumnSettings>
                                            <infra:EditingColumnSetting ColumnKey="ProjectID" ReadOnly="true" />
                                            <infra:EditingColumnSetting EditorID="txtProjectName" ColumnKey="ProjectName" />
                                            <infra:EditingColumnSetting EditorID="ddlReportingPeriod" ColumnKey="ReportingPeriod"/>
                                            <infra:EditingColumnSetting EditorID="txtProjectCreator" ColumnKey="ProjectCreator" />
                                            <infra:EditingColumnSetting EditorID="calProjectCreation" ColumnKey="ProjectCreation" />
                                        </ColumnSettings>
                                    </infra:CellEditing>
                                    <infra:RowAdding Alignment="Bottom" EditModeActions-MouseClick="Double"/>
                                    <infra:RowDeleting Enabled="true" />
                                </Behaviors>
                            </infra:EditingCore>
                            <infra:Sorting>
                                <ColumnSettings>
                                    <infra:SortingColumnSetting ColumnKey="ProjectID" />
                                    <infra:SortingColumnSetting ColumnKey="ProjectName" />
                                    <infra:SortingColumnSetting ColumnKey="ReportingPeriod" />
                                    <infra:SortingColumnSetting ColumnKey="ProjectCreator" />
                                    <infra:SortingColumnSetting ColumnKey="ProjectCreation" />
                                </ColumnSettings>
                            </infra:Sorting>
                            <infra:Paging PageSize="15" />
                        </Behaviors>
                        <EditorProviders>
                            <infra:TextEditorProvider ID="txtProjectName">
                                <EditorControl ClientIDMode="Predictable"/>
                            </infra:TextEditorProvider>
                            <infra:DropDownProvider ID="ddlReportingPeriod">
                                <EditorControl DataSourceID="sqlReportingPeriod" TextField="Name" ValueField="Value"
                                    EnableDropDownAsChild="False" DisplayMode="DropDownList" ClientIDMode="Predictable" DropDownContainerMaxHeight="200px"
                                >
                                    <DropDownItemBinding TextField="Name" ValueField="Value" />
                                </EditorControl>
                            </infra:DropDownProvider>
                            <infra:TextEditorProvider ID="txtProjectCreator">
                                <EditorControl ClientIDMode="Predictable"/>
                            </infra:TextEditorProvider>
                            <infra:WebDateChooserProvider ID="calProjectCreation"/>
                        </EditorProviders>
                        <AjaxIndicator Enabled="True" />
                    </infra:WebDataGrid>

                    <asp:SqlDataSource runat="server" ID="sqlProjects" ConnectionString="<%$ ConnectionStrings:HelloUranus %>"
                        SelectCommand="<%$ AppSettings:GetProjects %>" SelectCommandType="StoredProcedure"
                        InsertCommand="<%$ AppSettings:InsertProject %>" InsertCommandType="StoredProcedure"
                        UpdateCommand="<%$ AppSettings:UpdateProject %>" UpdateCommandType="StoredProcedure"
                        DeleteCommand="<%$ AppSettings:DeleteProject %>" DeleteCommandType="StoredProcedure"
                        OnSelecting="sqlProjects_Selecting"
                        OnUpdating="sqlProjects_Updating"
                    >
                        <SelectParameters>
                            <asp:Parameter Name="ProjectID" Type="Int32" />
                            <asp:Parameter Name="ProjectName" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    <asp:SqlDataSource runat="server" ID="sqlReportingPeriod" ConnectionString="<%$ ConnectionStrings:Floobarf %>"
                        SelectCommand="<%$ AppSettings:ReportingPeriods %>"
                    />

1 个答案:

答案 0 :(得分:1)

使用TemplateDataField时,模板中的控件将始终显示,除非您在模板中实现,否则这些单元格没有编辑模式。如果您正在寻找可以双击以编辑单元格的默认行为,那么您应该使用BoundDataField。如果这样做,那么网格将使用您在ColumnSettings中为CellEditing行为指定的编辑器。