A problem exists in the smartgridview control emptydatatemplate.

Source: Internet
Author: User
Tags one more line

The smartgridview control is used in the project. When binding data, if the data shows "no data" as a fantasy, it is directly bound with data.

Source codeAs follows:

Source code

 1 <Yyc: smartgridview runat = "  Server  " Id = "  Huahewu  " Autogeneratecolumns = "  False  " Cellpadding = "  0 "  2 Cellspacing = "  0  " Borderwidth = "  0  " Align = "  Center  " Allowpaging = "  True  " Onpageindexchanging = " Huahewu_pageindexchanging  " > 3 <Columns> 4 <Asp: templatefield headertext = "  Chinese name  " > 5 <Itemtemplate> 6 <A href = "  ../Compound/compoundbasicdetails. aspx? Id = <% # eval (  " Compoundid"  ) %>  " Title = "  <% # Eval (  " Chinname "  ) %>  "  7 Style = "  Color: Blue; text-Decoration: underline;  " > 8 <% # (System. Data. datarowview) container. dataitem )["  Chinname  " ] %> </A> 9 </Itemtemplate> 10 <Itemstyle width = "  25%  " /> 11 </ASP: templatefield> 12 <Asp: templatefield headertext = "  CAS No.  " >13 <Itemtemplate> 14 <% # (System. Data. datarowview) container. dataitem )[ "  Cas_number  " ] %> 15 </Itemtemplate> 16 <Itemstyle width = "  25%  " /> 17 </ASP: templatefield> 18 <Asp: templatefield headertext = "  Molecular formula  " > 19 <Itemtemplate> 20 <% # (System. Data. datarowview) container. dataitem )[ "  Molformula  " ] %> 21 </Itemtemplate> 22 <Itemstyle width = " 25%  " /> 23 </ASP: templatefield> 24 <Asp: templatefield headertext = "  Molecular Weight  " > 25 <Itemtemplate> 26 <% # (System. Data. datarowview) container. dataitem )[ "  Molweight  " ] %>27 </Itemtemplate> 28 <Itemstyle width = "  25%  " /> 29 </ASP: templatefield> 30 </Columns> 31 <Pagersettings position = "  Topandbottom  " /> 32 <Rowstyle cssclass = "  TR3  " Font-size = "  12px  " Height = "  28px  " /> 33 <Headerstyle cssclass = "  Itable_title  " /> 34 <Emptydatatemplate>35 <Tr Class = "  Itable_title  " > 36 <TD width = "  25%  " > 37   Chinese name  38 </TD> 39 <TD width ="  25%  " > 40   CAS No.  41 </TD> 42 <TD width = "  25%  " > 43   Molecular formula  44 </TD> 45 <TD width = "  25%  " > 46   Molecular Weight  47 </TD> 48 </Tr> 49 <Tr Class = "  TR3  " > 50 <TD colspan ="  4  " > 51   No data  52 </TD> 53 </Tr> 54 </Emptydatatemplate> 55 </Yyc: smartgridview>

Bind data in the background

Dataset DS =Whbll. checkhistory (historymodel );If(DS =Null| Ds. Tables. Count <=0| Ds. Tables [0]. Rows. Count <=0) {Datatable dt=Createtemptable (); grid_histroy.datasource=DT; grid_histroy.databind ();}Else{Grid_histroy.datasource= Ds. Tables [0]; Grid_histroy.databind ();}

After running the page, you will find that there is a problem with the page style.

Debug with Firefox and find the following style:

We can see that there is one more line, as shown in blue,

NowCodeModify:

Changed code

 1 Dt = Createtemptable ();  2 Datarow DR = DT. newrow ();  3 Dr [ "  Trans_id  " ] = ""  ;  4 Dr ["  Location_id  " ] = ""  ;  5 Dr [ "  Trans_date  " ] = ""  ;  6 Dr [ "  Contents  " ] = "" ;  7 Dr [ "  Unit  " ] = ""  ;  8 Dr [ "  Trans_by  " ] = ""  ;  9 Dr [ "  Trans_mode " ] = ""  ;  10   DT. Rows. Add (DR );  11               This . Grid_histroy.datasource = DT;  12               This  . Grid_histroy.databind ();  13               For ( Int I = 0 ; I <This . Grid_histroy.rows.count; I ++ )  14   {  15                   For ( Int J = 1 ; J < This . Grid_histroy.columns.count; j ++ )  16   {  17                       This . Grid_histroy.rows [I]. cells. removeat (1  );  18   }  19                   This . Grid_histroy.rows [I]. cells [ 0 ]. Columnspan = 7  ;  20                   This . Grid_histroy.rows [I]. cells [ 0 ]. Text = "  No historical information found  " ;  21 }

The result is as follows:

Problem Solving

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.