Monday, 5 January 2015

Working With Multiple DataKey in Gridview

Aspx Page:

<asp:GridView ID="GV_Report" runat="server" BackColor="White" BorderColor="White"
                        BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" AutoGenerateColumns="False"
                        GridLines="None" Width="100%" DataKeyNames="district_code,ro_code,query_no,query_year">
                        <Columns>

                    </asp:GridView>

.VB Page

 For Each row As GridViewRow In GV_Report.Rows
          
            DistrictCode = GV_Report.DataKeys(row.RowIndex).Values(0).ToString()
            ROCode = GV_Report.DataKeys(row.RowIndex).Values(1).ToString()
            QueryNo = GV_Report.DataKeys(row.RowIndex).Values(2).ToString().Substring(4, 10)
            QueryYear = GV_Report.DataKeys(row.RowIndex).Values(3).ToString()

         //Your Method
        Next