如何为变量分配列标题值

时间:2014-08-04 14:55:36

标签: vb.net aspxgridview

我有一个名为gvForecasts的ASPX gridview

这有一个标题为一年中的每一周;第1周第2周第3周等。

我希望能够遍历这些列以查明它是否小于今天的日期。但是要做到这一点,我需要首先弄清楚如何获取列标题值。

任何帮助都会很棒。

Asp ---->

<dx:ASPxGridView ID="gvForecasts" runat="server" ClientInstanceName="gvForecasts" AutoGenerateColumns="False" DataSourceID="ForecastData" Width="1171px" OnInit="gvForecasts_Init">
        <Columns>
            <dx:GridViewDataTextColumn FieldName="Customer" VisibleIndex="0">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="StockCode" VisibleIndex="2">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="3" Width="300px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Quantity" VisibleIndex="4">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="WeeksStock" VisibleIndex="5">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 1 " FieldName="Week_1" VisibleIndex="7">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 2 " VisibleIndex="8" FieldName="Week_2">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 3" VisibleIndex="9" FieldName="Week_3">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 4" VisibleIndex="10" FieldName="Week_4">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 5" VisibleIndex="11" FieldName="Week_5">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 6 " VisibleIndex="12" FieldName="Week_6">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 7" VisibleIndex="13" FieldName="Week_7">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 8" VisibleIndex="14" FieldName="Week_8">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 9" VisibleIndex="15" FieldName="Week_9">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 10" VisibleIndex="16" FieldName="Week_10">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 11" VisibleIndex="17" FieldName="Week_11">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 12" VisibleIndex="18" FieldName="Week_12">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 13" VisibleIndex="19" FieldName="Week_13">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 14" VisibleIndex="20" FieldName="Week_14">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 15" VisibleIndex="21" FieldName="Week_15">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 16" VisibleIndex="22" FieldName="Week_16">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 17" VisibleIndex="23" FieldName="Week_17">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 18" VisibleIndex="24" FieldName="Week_18">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 19" VisibleIndex="25" FieldName="Week_19">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 20" VisibleIndex="26" FieldName="Week_20">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 21" VisibleIndex="27" FieldName="Week_21">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 22" VisibleIndex="28" FieldName="Week_22">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 23" VisibleIndex="29" FieldName="Week_23">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 24" VisibleIndex="30" FieldName="Week_24">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 25" VisibleIndex="31" FieldName="Week_25">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 26" VisibleIndex="32" FieldName="Week_26">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 27" VisibleIndex="33" FieldName="Week_27">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 28" VisibleIndex="34" FieldName="Week_28">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 29" VisibleIndex="35" FieldName="Week_29">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 30" VisibleIndex="36" FieldName="Week_30">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 31" VisibleIndex="37" FieldName="Week_33">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 32" VisibleIndex="38" FieldName="Week_32">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 33" VisibleIndex="39" FieldName="Week_33">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 34" VisibleIndex="40" FieldName="Week_34">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 35" VisibleIndex="41" FieldName="Week_35">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 36" VisibleIndex="42" FieldName="Week_36">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 37" VisibleIndex="43" FieldName="Week_37">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 38" VisibleIndex="44" FieldName="Week_38">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 39" VisibleIndex="45" FieldName="Week_39">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 40" VisibleIndex="46" FieldName="Week_40">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 41" VisibleIndex="47" FieldName="Week_41">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 42" VisibleIndex="48" FieldName="Week_42">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 43" VisibleIndex="49" FieldName="Week_43">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 44" VisibleIndex="50" FieldName="Week_44">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 45" VisibleIndex="51" FieldName="Week_45">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 46" VisibleIndex="52" FieldName="Week_46">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 47" VisibleIndex="53" FieldName="Week_47">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 48" VisibleIndex="54" FieldName="Week_48">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 49" VisibleIndex="55" FieldName="Week_49">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 50" VisibleIndex="56" FieldName="Week_50">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 51" VisibleIndex="57" FieldName="Week_51">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Week 52" VisibleIndex="58" FieldName="Week_52">
            </dx:GridViewDataTextColumn>
        </Columns>
        <SettingsPager PageSize="30">
            <PageSizeItemSettings Visible="True">
            </PageSizeItemSettings>
        </SettingsPager>
        <Settings HorizontalScrollBarMode="Visible" VerticalScrollBarMode="Visible" VerticalScrollableHeight="500" ShowFilterRow="True" ShowFilterRowMenu="True" />
    </dx:ASPxGridView>

Init事件如下;

Protected Sub gvForecasts_Init(sender As Object, e As EventArgs)

        Dim dat As String = DatePart(DateInterval.WeekOfYear, Now)
        Dim WeekNum As String = "Week " & dat

    End Sub

0 个答案:

没有答案