DetailsView in CSS Friendly

Source: Internet
Author: User
After implementing the NBearDataSource control-02-11 revision-added the Master/Detail object CRUD example Example of a Master/Detail object CRUD Based on NBearDataSource

If you use CSS Friendly ASP. NET 2.0 Control Adapters 1.0, the following code
1 <nb: NBearDataSource ID = "nbdsLinkCategorys" runat = "server" ConnectionStringName = "Access"
2 TypeName = "MK2.Community. Entities. LinkCategory" EnableViewState = "true">
3 </nb: NBearDataSource>
4 <asp: DetailsView ID = "DetailsView1" runat = "server" performanceid = "nbdsLinkCategorys" DefaultMode = "Insert"
5 AutoGenerateInsertButton = "true" AutoGenerateRows = "false">
6 <Fields>
7 <asp: BoundField DataField = "Name" HeaderText = "Name"/>
8 </Fields>
9 </asp: DetailsView>

You only need to set the DetailsView attribute DefaultMode = "Insert" AutoGenerateInsertButton = "true" AutoGenerateRows = "false"
An exception occurs:
The index is out of the range. It must be a non-negative value and smaller than the set size.
Parameter Name: index

Note:An error occurred while executing the current Web request. Check the stack trace information for details about the error and the source of the error in the code.

Exception details:System. ArgumentOutOfRangeException: The index is out of the range. It must be a non-negative value and smaller than the set size.
Parameter Name: index

Source error:

Row 57: {row 58: DetailsViewRow row = ControlAsDetailsView. Rows [iRow]; row 59: if ((! ControlAsDetailsView. AutoGenerateRows) & row 60: (row. RowState & DataControlRowState. Insert) = DataControlRowState. Insert) & row 61 :(! ControlAsDetailsView. Fields [row. RowIndex]. InsertVisible ))

Source file:XXXXX \ WebSite \ App_Code \ Adapters \ DetailsViewAdapter. csRow:59

I modified the source code, so that I can work with 1 DetailsViewRow row = ControlAsDetailsView. Rows [iRow];
2 // if ((! ControlAsDetailsView. AutoGenerateRows )&&
3 // (row. RowState & DataControlRowState. Insert) = DataControlRowState. Insert )&&
4 //(! ControlAsDetailsView. Fields [row. RowIndex]. InsertVisible ))
5 //{
6 // continue;
7 //}
8
9 // Fix by MK2
10 if ((! ControlAsDetailsView. AutoGenerateRows )&&
11 (row. RowState & DataControlRowState. Insert) = DataControlRowState. Insert ))
12 {
13 if (iRow <ControlAsDetailsView. Fields. Count )&&
14 (! ControlAsDetailsView. Fields [row. RowIndex]. InsertVisible ))
15 {
16 continue;
17}
18}
19 // Fix over

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.