About the case sensitivity of the name bound to asp.net.

Source: Internet
Author: User
I used to have a hard time understanding about the case sensitivity of the binding name for Data Binding. I found a batch of articles just now and thought it was very clear after reading them. I excerpted the article below.

The order of UpdateParameters and InsertParameters parameters must be the same as that of method parameters. Otherwise, an exception is thrown, indicating that no such exception method is available.
For example, if the UpdateMethod method of ObjectDataSource is Update (string a, string B, int c), you should write the UpdateParameters parameter as follows:
<UpdateParameters>
<Asp: Parameter Name = "a" Type = "String"/>
<Asp: Parameter Name = "B" Type = "String"/>
<Asp: Parameter Name = "c" Type = "Int32"/>
</UpdateParameters>

2.
When using ObjectDataSource, I found that the parameters in the Data Display Control and ObjecDataSource parameters can be case-insensitive, but when reading parameters in the event, the parameter name must be the same as that set by ObjectDataSource. It is case sensitive.
The following code: <asp: FormView ID = "fv" runat = "server" DefaultMode = "Insert" performanceid = "odsFV" OnItemUpdated = "fv_ItemUpdated"
OnItemInserting = "fv_ItemInserting" OnItemInserted = "fv_ItemInserted">
<InsertItemTemplate>
Name:
<Asp: TextBox ID = "TravelArticleTitleTextBox" runat = "server" Text = '<% # Bind ("travelArticleTitle") %>'>
</Asp: TextBox> <br/>
</InsertItemTemplate>
</Asp: FormView>
<Asp: ObjectDataSource ID = "odsFV" runat = "server" InsertMethod = "Insert" OldValuesParameterFormatString = "original _ {0 }"
SelectMethod = "GetTravelArticleByTravelArticleID" TypeName = "Obj. BLL. TravelArticleBLL"
UpdateMethod = "Update" OnInserting = "odsFV_Inserting">
<SelectParameters>
<Asp: QueryStringParameter Name = "travelArticleID" QueryStringField = "TravelArticleID"
Type = "Int32"/>
</SelectParameters>
<InsertParameters>
<Asp: CookieParameter CookieName = "UserID" Name = "userid" Type = "String"/>
<Asp: Parameter Name = "travelArticleTitle" Type = "String"/>
</InsertParameters>
</Asp: ObjectDataSource>

Where: <asp: TextBox ID = "TravelArticleTitleTextBox" runat = "server" Text = '<% # Bind ("travelArticleTitle") %>'>
</Asp: TextBox> Text = '<% # Bind ("travelArticleTitle") %>' can beText = '<% # Bind ("TravelArticleTitle") %>'

However, the background reads parameters in the event, such as protected void fv_ItemInserting (object sender, FormViewInsertEventArgs e ){}
We must write e. Values ["travelArticleTitle"] instead E. Values ["TravelArticleTitle"]
Otherwise, we cannot read the value! This may be a problem that many people encounter, so I wrote it out. It may be helpful to everyone.

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.