Use the ASP + DataGrid control to create the master View/details View (2)

Source: Internet
Author: User
Step6Page. cs:
Namespace Samples {
...
Public class Step6Page: Page {
// Update the selected author and reload the title corresponding to the selected content
// Grid
Protected void LoadTitlesGrid (){
UpdateSelection ();
TitlesGrid. DataBind ();
}
// Process the CancelCommand event in the title grid
// Stop editing without applying changes
Protected void OnCancelCommandTitlesGrid (object sender,
DataGridCommandEventArgs e ){
TitlesGrid. EditItemIndex =-1;
LoadTitlesGrid ();
}
// Process the EditCommand event in the title grid
// Start editing a row
Protected void OnEditCommandTitlesGrid (object sender,
DataGridCommandEventArgs e ){
TitlesGrid. EditItemIndex = e. Item. ItemIndex;
LoadTitlesGrid ();
}
// Process the UpdateCommand event in the title grid to apply
// Changes and end editing
Protected void OnUpdateCommandTitlesGrid (object sender,
DataGridCommandEventArgs e ){
TextBox priceText =
(TextBox) e. Item. FindControl ("Column3Control ");
String newPrice = priceText. Text. Substring (1 );
DataSet ds = GetSessionData ();
DataTable titlesTable = ds. Tables ["Title"];
String titleID =
(String) titlesGrid. DataKeys [e. Item. ItemIndex];
DataRow [] rows = titlesTable. Select ("title_id = '" +
TitleID + "'");
DataRow editRow = rows [0];
EditRow. BeginEdit ();
EditRow ["price"] = newPrice;
EditRow. EndEdit ();
EditRow. AcceptChanges ();

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.