Wednesday, December 14, 2011

Display the values of particular Cell of GridView in asp.net with vb

Example:

in .aspx page


<div>
    
        <asp:GridView ID="GridView1" runat="server">
        </asp:GridView>
    
    </div>
    <p>
        <asp:Button ID="Btndisplayvalue" runat="server" Text="Button" />
    </p>


in .vb page


 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim a As String
        a = "anish"
        GridView1.DataSource = a
        GridView1.DataBind()


    End Sub


    


    Protected Sub Btndisplayvalue_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btndisplayvalue.Click
        Dim dr As GridViewRow
        For Each dr In GridView1.Rows
            Response.Write(dr.Cells(0).Text)
        Next
    End Sub




it will display values of cell(0) present in GridView1

No comments:

Post a Comment