質問

I have a DataGrid item on an aspx page. The columns are BoundColumns that are populated through a DataSource/DataBind from an Oracle query.

What I am trying to do is add a title attribute to each of the column headers

What I have is

<asp:datagrid id="DataGrid1" runat="server" OnItemCreated="DataGrid1_ItemCreated">

among other attributes

and then when the items are created I have a C#.net event trigger

protected void DataGrid1_ItemCreated(object sender, DataGridItemEventArgs e){

I have found out how to add the title attribute to a row, and even explicitly the Header row, but not how to parse out the individual headers

I have been using:

if(e.Item.Cells[0] = "&nbsp;"){
    e.Item.Attributes.Add("title", "Project Title";
}

I haven't yet found a way to access the text of the header, or the individual text value within the row. Any advice is appreciated, Thanks.

役に立ちましたか?

解決

here's what i did:

protected void DataGrid1_ItemCreated(object sender, DataGridItemEventArgs e){
    for(int i = 0; i < e.Item.Cells.Count; i++){
        e.Item.Cells[i].Attributes.Add("title", DataGrid1.Columns[i].HeaderText);
    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top