How to get row values of a certain column on ASPXGridView

jeffry picture jeffry · Dec 18, 2013 · Viewed 11.5k times · Source

I have a ASPXGridView and I want to know how to get values from the grid, I want to get the 'Vendor Name' and 'Band Name' values for each row. I only want the values from these columns.

Do i need to look at the DataSource or?

I have attached a pic, the grid i am working on is the bottom one. All Restriction for this customer.

enter image description here

Here is the markup for the bottom grid.

    <dxwgv:ASPxGridView ID="GVFullResults" 
        runat="server" Width="100%" 
        AutoGenerateColumns="False" DataSourceID="ODSFullResultsGrid" 
        KeyFieldName="Id">
        <SettingsBehavior ConfirmDelete="True" />
        <Styles>
            <Header BackColor="#CCCCFF" Font-Bold="True" Font-Names="Arial" 
                Font-Size="10px">
            </Header>
        </Styles>
        <Columns>
            <dxwgv:GridViewCommandColumn Caption="Edit" VisibleIndex="0" Width="55px">
                <EditButton Visible="True">
                </EditButton>
                <DeleteButton Visible="True">
                </DeleteButton>
            </dxwgv:GridViewCommandColumn>
            <dxwgv:GridViewDataTextColumn FieldName="CarrierId" VisibleIndex="1" 
                Caption="Vendor" Width="35px">
                <EditFormSettings Visible="False" />
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="CarrierName" VisibleIndex="2" 
                Width="140px" Caption="Vendor Name">
                <EditFormSettings Visible="False" />
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="CustomerId" VisibleIndex="3" 
                Caption="Customer" Width="45px">
                <EditFormSettings Visible="False" />
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="CustomerName" VisibleIndex="4" 
                Width="140px">
                <EditFormSettings Visible="False" />
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="BandId" VisibleIndex="5" 
                Caption="Band" Width="45px">
                <EditFormSettings Visible="False" />
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="BandName" VisibleIndex="6" 
                Width="140px">
                <EditFormSettings Visible="False" />
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="Restriction" VisibleIndex="7" 
                Width="50px">
                <EditFormSettings Visible="False" />
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="DateCreated" VisibleIndex="8">
                <EditFormSettings Visible="False" />
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="CreatedBy" VisibleIndex="9" 
                Width="55px">
                <EditFormSettings Visible="False" />
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="Comments" VisibleIndex="10">
                <EditFormSettings CaptionLocation="None" />
                <EditItemTemplate>
                    <div style="float:right">
                    Comments:
                    <dxe:ASPxMemo ID="CommentsMemo" runat="server" Height="71px" Width="170px">
                    </dxe:ASPxMemo>
                    </div>
                </EditItemTemplate>
                <CellStyle>
                    <Border BorderColor="Silver" BorderStyle="Solid" />
                </CellStyle>
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn Caption="Id" FieldName="Id" Visible="False" 
                VisibleIndex="11">
                <EditFormSettings Visible="False" />
            </dxwgv:GridViewDataTextColumn>
        </Columns>
        <SettingsPager PageSize="75">
        </SettingsPager>
        <Settings ShowVerticalScrollBar="True" VerticalScrollableHeight="300" />
    </dxwgv:ASPxGridView>

Answer

thewisegod picture thewisegod · Dec 18, 2013

Try this.

int indexOfColumnToGet = some number;
gridview.Rows[rowIndex].Cells[indexOfColumnToGet].Text