如何制作填充网格的功能? [英] how to make a function for fill a grid ?

查看:96
本文介绍了如何制作填充网格的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 私有  Sub  gridfill()
ds = employee.Getsearchemp(Trim(txtsearch.Text))
Gridsearch.RowCount = 0
For i 作为 整数 = 0 ds.Tables( 0 )。Rows.Count - 1
Gridsearch.RowCount + = 1
Gridsearch(Gridsearch.RowCount, 1 )。CellValue = ds.Tables( 0 )。行(i)( < span class =code-string> regionname)
Gridsearch(Gridsearch.RowCount, 2 )。CellValue = ds.Tables(< span class =code-digit> 0 )。行(i)( unitname
Gridsearch(Gridsearch.RowCount, 3 )。CellValue = ds.Tables( 0 )。行(i)( < span class =code-string> first_name)
Gridsearch(Gridsearch.RowCount, 4 )。CellValue = ds.Tables(< span class =code-digit> 0 )。行(i)( fathername
Gridsearch(Gridsearch.RowCount, 5 )。CellValue = ds.Tables( 0 )。行(i)( DOB
Gridsearch(Gridsearch.RowCount, 6 )。CellValue = ds.Tables( 0 )。行(i)( namesname
Gr idsearch(Gridsearch.RowCount, 7 )。CellValue = ds.Tables( 0 )。行(i) ( probation_date
Gridsearch(Gridsearch.RowCount, 8 )。CellValue = ds.Tables( 0 )。行(i)( DOJ
Gridsearch(Gridsearch.RowCount, 9 )。CellValue = ds .Tables( 0 )。行(i)( 辞职日期
下一步
结束 Sub







我正在使用此并获取错误

行数'不是'system.web.ui.webcontrols.gridview 的成员

提前感谢解决方案

您可以将数据集直接绑定到gridview

 Gridsearch.DataSource = ds 
Gridsearch .DataBind()



如果你需要获取行数,请尝试 Gridsearch.Rows.Count property


Private Sub gridfill()
        ds = employee.Getsearchemp(Trim(txtsearch.Text))
        Gridsearch.RowCount = 0
        For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
            Gridsearch.RowCount += 1
            Gridsearch(Gridsearch.RowCount, 1).CellValue = ds.Tables(0).Rows(i)("regionname")
            Gridsearch(Gridsearch.RowCount, 2).CellValue = ds.Tables(0).Rows(i)("unitname")
            Gridsearch(Gridsearch.RowCount, 3).CellValue = ds.Tables(0).Rows(i)("first_name")
            Gridsearch(Gridsearch.RowCount, 4).CellValue = ds.Tables(0).Rows(i)("fathername")
            Gridsearch(Gridsearch.RowCount, 5).CellValue = ds.Tables(0).Rows(i)("DOB")
            Gridsearch(Gridsearch.RowCount, 6).CellValue = ds.Tables(0).Rows(i)("designationname")
            Gridsearch(Gridsearch.RowCount, 7).CellValue = ds.Tables(0).Rows(i)("probation_date")
            Gridsearch(Gridsearch.RowCount, 8).CellValue = ds.Tables(0).Rows(i)("DOJ")
            Gridsearch(Gridsearch.RowCount, 9).CellValue = ds.Tables(0).Rows(i)("Resignation Date")
        Next
    End Sub




i'm using this and get error
row count' is not a member of 'system.web.ui.webcontrols.gridview
thanks in advance

解决方案

you can bind dataset directly to a gridview

Gridsearch.DataSource = ds
    Gridsearch.DataBind()


if you need to get row count, try Gridsearch.Rows.Count property


这篇关于如何制作填充网格的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆