Footerrow cannot be found when the gridview data source is empty

Source: Internet
Author: User

You can use the following statement to locate the gridview command event:

Gridviewrow=(Control) E. commandsource). bindingcontainerAsGridviewrow;

 

You can use the following statement to find the control event in the gridview: Gridviewrow=(SenderAsTextbox). Parent. ParentAs Gridviewrow;
String Itemno = (Textbox) (gridviewrow. findcontrol ( " Textboxpartnonew " ). Text. Trim ();

How can I find it in page_load?

The following information from: http://www.itzhe.cn/html/web/ASP.NET/20071127/22928_2.html

Problems encountered when using the gridview to implement the insert Function

// Create a new header row
Gridviewrow headerrow =   Base . Createrow ( - 1 , - 1 , Datacontrolrowtype. header, datacontrolrowstate. Normal );
This . Initializerow (headerrow, fields );

//Add the header row to the table
Table. Rows. Add (headerrow );
}

// Create the empty row
Gridviewrow emptyrow =   New Gridviewrow ( - 1 , - 1 , Datacontrolrowtype. emptydatarow, datacontrolrowstate. Normal );
Tablecell Cell =   New Tablecell (); itzhe.cn
Cell. columnspan = Fields. length;
Cell. Width = Unit. percentage ( 100 );

// Respect the precedence order if both emptydatatemplate
// And emptydatatext are both supplied
If ( This . Emptydatatemplate ! =   Null )
{
This . Emptydatatemplate. instantiatein (cell );
}
Else   If ( ! String . Isnullorempty ( This . Emptydatatext ))
{
Cell. Controls. Add ( New Literalcontrol (emptydatatext ));
IT staff

}

Emptyrow. cells. Add (cell );
Table. Rows. Add (emptyrow );

// If (this. showfooterwhenempty)
// {
// Create footer row
Gridviewrow footerrow =   Base . Createrow ( - 1 , - 1 , Datacontrolrowtype. footer, datacontrolrowstate. Normal );
This . Initializerow (footerrow, fields );

//Add the footer to the table
Table. Rows. Add (footerrow );
//}

This. Controls. Clear ();
Www.itzhe.cn

This. Controls. Add (table );
This. Showfooter= True;
}
ReturnRows;

}
}

The function is implemented. When no data is available, both the header and footer can be displayed. I put all the items to be entered for data insertion in footer. Therefore, when no data is available, an insert record will always be displayed, however, after I submit the request, the gridview. footerrow. findcontrol ("tb_foot_name") returns a null value. However, if the table contains data, the gridview. footerrow. findcontrol ("tb_foot_name") can return objects. The difference is:
However, if there is no data, footer is created by myself, and if there is data, footer is created by the system.
How can I help you?

Thank you.
This articleArticleSource from www.itzhe.cn Original article link: http://www.itzhe.cn/html/web/ASP.NET/20071127/22928_2.html

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.