如何为gridview赋值

时间:2014-07-09 11:59:21

标签: c# gridview

我有一些问题吗?如果我想为gridview中的列赋值,而该列没有DataField。可以这样做。因为我的数据表中没有gridview中的列。例如

我的DataTable有6列{id,code,description,price1,price2,price3} 这是我的gridview

<asp:GridView ID="gridview" runat="server" AutoGenerateColumns="False" CssClass="table table-hover table-striped" OnRowCancelingEdit="gridview_RowCancelingEdit1" OnRowEditing="gridview_RowEditing1" OnRowUpdating="gridview_RowUpdating">
                        <Columns>
                            <asp:CommandField ButtonType="Button" ShowEditButton="True" ControlStyle-CssClass="btn btn-primary" HeaderStyle-Width="80" >
                                <ControlStyle CssClass="btn btn-primary"></ControlStyle>
                                <HeaderStyle Width="80px"></HeaderStyle>
                            </asp:CommandField>

                            <asp:BoundField DataField="ITM_RowId" HeaderText="No." ReadOnly="true" HeaderStyle-Width="80" />
                            <asp:BoundField DataField="ITM_Code" HeaderText="ItemCode" HeaderStyle-Width="80" />
                            <asp:BoundField DataField="ITM_Desc" HeaderStyle-Width="80" HeaderText="Item Descrition" />
                            <asp:BoundField DataField="OPD_Price" HeaderStyle-Width="80" HeaderText="Existing OPD Price" />
                            <asp:BoundField DataField="IPD_Price" HeaderStyle-Width="80" HeaderText="Existing IPD Price" />
                            <asp:BoundField DataField="Tou_Price" HeaderStyle-Width="80" HeaderText="Existing Tourist Price" />
                            <asp:BoundField HeaderText="New OPD Price" HeaderStyle-Width="80" />
                            <asp:BoundField HeaderText="New IPD Price" HeaderStyle-Width="80" />
                            <asp:BoundField HeaderText="New Tourist Price" HeaderStyle-Width="80" />
                            <asp:BoundField HeaderStyle-Width="80" HeaderText="Margin OPD Price" />
                            <asp:BoundField HeaderStyle-Width="80" HeaderText="Margin IPD Price" />
                            <asp:BoundField HeaderStyle-Width="80" HeaderText="Margin Tourist Price" />     
                        </Columns>
                    </asp:GridView>
                <asp:HiddenField ID="hdf" runat="server" />  

in case case {ITM_RowId,ITM_Code,ITM_Desc,OPD_Price(price1),IPD_Price(price2),tou_Price(price3)}没有问题,但是如果我想为列{Margin OPD Price,Margin IPD Price&#赋值34;,保证金旅游价格}它可能吗?

0 个答案:

没有答案