2009-06-02 20 views
2

我知道有一个解决方案,但我在努力得到它转换为正确VB :(显示表头时的GridView是空VB.net

我已经得到了一个级联组的下拉列表中的/页脚与

但是由于后根据每个人的结果数据,我真的很高兴。回到网格将消失,直到第二个值被选中,看起来可怕

反正是有内VB,使头如果网格视图中没有数据,请坚持使用?

非常感谢提前。

回答

2

你有2种方法来做到这一点:

1,通过模拟输入字段内

<asp:GridView ID="GridView1" runat="server"> 
     <EmptyDataTemplate> 
      <tr> 
       <td> 
        First Cell 
       </td> 
       <td> 
        Second Cell 
       </td> 
       <tb> 
        Third Cell 
       </tb> 
      </tr> 
     </EmptyDataTemplate> 
     </asp:GridView> 

2-是创建空DataSet并将其绑定到GirdView。

If ds.Tables(0).Rows.Count > 0 Then 
      grd_codes.DataSource = ds 
      grd_codes.DataMember = ds.Tables(0).TableName 

      grd_codes.DataBind() 

     Else 
      Try 
       If ds.Tables(0).Rows.Count = 0 Then 

        ds.Tables(0).Rows.Add(ds.Tables(0).NewRow()) 
        grd_codes.DataSource = ds 
        grd_codes.DataBind() 
        Dim columnCount As Integer = grd_codes.Rows(0).Cells.Count 
        grd_codes.Rows(0).Cells.Clear() 
        grd_codes.Rows(0).Cells.Add(New TableCell) 
        grd_codes.Rows(0).Cells(0).ColumnSpan = columnCount 
        grd_codes.Rows(0).Cells(0).Text = "No Records Found." 

       End If 

我更喜欢第一种方式,因为绑定空的DataSet有一些问题。