【发布时间】:2017-11-02 14:48:06
【问题描述】:
我有一个有 BoundColumn 的数据网格,我正在尝试更改页面加载时的标题文本。我试过这个。
<asp:datagrid id="dgdata" runat="server" Width="658px" CellPadding="2" PageSize="2" DataKeyField="Name"
AutoGenerateColumns="False" ShowFooter="True" BorderColor="AliceBlue" OnItemDataBound="dgTranscript_ItemDataBound">
<Columns>
<asp:BoundColumn DataField="Name" HeaderText="" ItemStyle-VerticalAlign="Top"></asp:BoundColumn>
</Columns>
</asp:datagrid>
C#
dgdata.Columns[1].Visible = true;
dgdata.Columns[1].HeaderText = lblAverage.Text
我想将文本设置为该标签内的文本,但如果我说没有标签,它不会让我工作
dgdata.Columns[1].Visible = true;
dgdata.Columns[1].HeaderText = "Some Text";
绑定数据
DataSet ds;
DataRow drClient = null;
dgdata.Columns[1].HeaderText = lblAverage.Text; // Here before the Daatabind I set the text to be that label
DataConn.WebExecute(out ds);
DataConn.Bind(dgTranscript, ds);// This binds the data to the datagrid
它将文本显示为标题,但是当我尝试插入任何字符串或标签文本时,它会拒绝整个标题消失 提前致谢。最好的问候
【问题讨论】:
标签: c# asp.net datagrid boundfield headertext