Item 复选框从何而来

发布于 2024-11-11 18:15:28 字数 4072 浏览 5 评论 0原文

我目前有一个DetailsView(曾经是一个Formview,但那是与Masterpage 和ObjectDataSource 无关的)。

不知何故,图形中有一个“项目[]”(复选框),我在源代码中找不到。 以图形方式可以在“Kommentar:”之后和“Dato:”之前找到它

                <asp:DetailsView ID="dv_InsertComment" runat="server" DefaultMode="Insert" DataSourceID="ods_InsertComment"
                    HeaderText="Kommentar:">
                    <Fields>
                        <asp:TemplateField HeaderText="Dato:">
                            <InsertItemTemplate>
                                <asp:Label ID="dNow" runat="server" Text='<%# DateTime.Now.ToShortDateString() %>'></asp:Label>
                            </InsertItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Konto" Visible="false">
                            <InsertItemTemplate>
                                <asp:TextBox ID="tbAccountIns" runat="server"></asp:TextBox>
                            </InsertItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Kommentar:">
                            <InsertItemTemplate>
                                <asp:TextBox ID="tbCommentIns" runat="server" Rows="3" Columns="50" TextMode="MultiLine"></asp:TextBox>
                            </InsertItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Status:">
                            <InsertItemTemplate>
                                <asp:DropDownList ID="StatusList" runat="server" DataSourceID="ods_StatusOptions"
                                    DataTextField="name">
                                </asp:DropDownList>
                            </InsertItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Fremnotering:">
                            <InsertItemTemplate>
                                <asp:DateBox ID="dFuture" runat="server" AllowNullDate="true" />
                            </InsertItemTemplate>
                        </asp:TemplateField>
                        <asp:ButtonField ButtonType="Button" Text="Indsæt kommentar" CommandName="Insert" />
                        <asp:ButtonField ButtonType="Button" Text="Annuller" CommandName="Cancel" />
                    </Fields>
                </asp:DetailsView>

,参数列表顶部需要一个“!”在新日期之后。又名它需要:“员工、帐户、评论、类型、状态、新日期,!”。

                <asp:ObjectDataSource ID="ods_InsertComment" runat="server" InsertMethod="InsertComment"
                    TypeName="OurClient.Host.CommentsBLL" SelectMethod="GetNothing">
                    <InsertParameters>
                        <asp:SessionParameter Name="employee" SessionField="employee" DbType="String" />
                        <asp:Parameter Name="Account" DbType="String" />
                        <asp:Parameter Name="Comment" DbType="String" />
                        <asp:Parameter Name="Type" DefaultValue="0" DbType="Int32" />
                        <asp:Parameter Name="Status" DbType="Int32" />
                        <asp:Parameter Name="NewDate" DbType="DateTime" />
                    </InsertParameters>
                </asp:ObjectDataSource>

我在想如果我删除该项目和复选框,“!”参数也会消失。但如果它不存在我该如何删除它?

我删除了整个 只是保留了 Item []。我将 DefaultMode="Insert" 移出,并且 Item [] 变为灰色(不可点击)。正如我在开始时所说的 - DetailsView 是一个解决方案,而不是 FormView

在询问 GetNothing 是否是一项要求之前,它必须定义一个 SelectMethod。除非它存在,否则无法编译它。

解决方案: 上的 AutoGenerateRows="False"

我是如何发现这个的?我转到有问题的 aspx,更改为拆分视图,并继续分析实际存在的控件。我偶然发现了“自动生成”复选框。

I currently have a DetailsView (used to be a Formview, but that is a nogo with Masterpage and ObjectDataSource).

Somehow there is an "Item [ ]" (tickbox) in the graphics that I can't find in the source.
It is graphically found after the "Kommentar:" and before the "Dato:"

                <asp:DetailsView ID="dv_InsertComment" runat="server" DefaultMode="Insert" DataSourceID="ods_InsertComment"
                    HeaderText="Kommentar:">
                    <Fields>
                        <asp:TemplateField HeaderText="Dato:">
                            <InsertItemTemplate>
                                <asp:Label ID="dNow" runat="server" Text='<%# DateTime.Now.ToShortDateString() %>'></asp:Label>
                            </InsertItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Konto" Visible="false">
                            <InsertItemTemplate>
                                <asp:TextBox ID="tbAccountIns" runat="server"></asp:TextBox>
                            </InsertItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Kommentar:">
                            <InsertItemTemplate>
                                <asp:TextBox ID="tbCommentIns" runat="server" Rows="3" Columns="50" TextMode="MultiLine"></asp:TextBox>
                            </InsertItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Status:">
                            <InsertItemTemplate>
                                <asp:DropDownList ID="StatusList" runat="server" DataSourceID="ods_StatusOptions"
                                    DataTextField="name">
                                </asp:DropDownList>
                            </InsertItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Fremnotering:">
                            <InsertItemTemplate>
                                <asp:DateBox ID="dFuture" runat="server" AllowNullDate="true" />
                            </InsertItemTemplate>
                        </asp:TemplateField>
                        <asp:ButtonField ButtonType="Button" Text="Indsæt kommentar" CommandName="Insert" />
                        <asp:ButtonField ButtonType="Button" Text="Annuller" CommandName="Cancel" />
                    </Fields>
                </asp:DetailsView>

Ontop of that the parameter list requires a "!" after NewDate. Aka it requires: "employee, Account, Comment, Type, Status, NewDate, !."

                <asp:ObjectDataSource ID="ods_InsertComment" runat="server" InsertMethod="InsertComment"
                    TypeName="OurClient.Host.CommentsBLL" SelectMethod="GetNothing">
                    <InsertParameters>
                        <asp:SessionParameter Name="employee" SessionField="employee" DbType="String" />
                        <asp:Parameter Name="Account" DbType="String" />
                        <asp:Parameter Name="Comment" DbType="String" />
                        <asp:Parameter Name="Type" DefaultValue="0" DbType="Int32" />
                        <asp:Parameter Name="Status" DbType="Int32" />
                        <asp:Parameter Name="NewDate" DbType="DateTime" />
                    </InsertParameters>
                </asp:ObjectDataSource>

I'm thinking if I remove the Item and tickbox, the "!" parameter will go away too. But if it is not there how do I remove it?

I have removed the entire <Fields></Fields> just to have only the Item [] remaining. I moved the DefaultMode="Insert" out and the Item [] went grey (not clickable). As I said in the beginning - the DetailsView is a solution instead of a FormView.

Before you ask the GetNothing is a requirement, it must have a SelectMethod defined. Can't compile it unless it's there.

Solution: AutoGenerateRows="False" on <asp:detailsview ....>

How did I spot that one? I went to the aspx in question, changed to the Split view and continued to analyse what controls were actually present. I kinda stumbled over the Auto Generate checkbox.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆伤 2024-11-18 18:15:28

您搜索过代码隐藏文件吗?

也许复选框被注入了?

复选框的id是“ContentPlaceHolder2_dv_InsertComment_ctl01”,这可能是动态添加的控件。

检查代码隐藏文件中是否有任何字符串,例如“InsertComment”或“dv_”或“_dv”等,然后查看。

我只是猜测当然。

Have you searched the code-behind file?

Maybe the checkbox is injected?

The id of the checkbox is "ContentPlaceHolder2_dv_InsertComment_ctl01", that could be a control which was added dynamically.

Check your code-behind file for any string like "InsertComment" or "dv_" or "_dv", etc. and have a look.

I'm only guessing off course.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文