我有一个ASPXGridView,我想知道如何从网格中获取值,我想获得每行的'Vendor Name'和'Band Name'值。我只想要这些列中的值。
我需要查看DataSource还是?
我附上了一张照片,我正在拍摄的网格是最底层的。对该客户的所有限制。
这是底部网格的标记。
<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>
答案 0 :(得分:2)
试试这个。
int indexOfColumnToGet = some number;
gridview.Rows[rowIndex].Cells[indexOfColumnToGet].Text
答案 1 :(得分:1)
如果我理解正确,这应该有用..
foreach(GridViewRow gvr in gvGridView1.Rows)
{
((Label)gvr.FindControl("lblVendorName")).Text;
((Label)gvr.FindControl("lblBandName")).Text;
}