Acessing gridview data programmatially

F

Fernando Monteiro

Hello,

Could anyone please help me ?

I've a GridView and I'd like to insert one of the girdview's dataset field as a
row tooltip.

The grid view is declared like:

<asp:GridView ID="grdLista" runat="server" DataSourceID="sdsList"
OnRowDataBound="grdLista_RowDataBound" AllowPaging="True" AllowSorting="True"
OnDataBound="grdLista_DataBound" AutoGenerateColumns="False" PageSize="25">
<Columns>
<asp:HyperLinkField HeaderText="Col1" DataNavigateUrlFields="field1"
DataNavigateUrlFormatString="page.aspx?PPage=page1&Id={0}"
InsertVisible="False" DataTextField="databaseField1" />
<asp:BoundField DataField="Description" Visible="false"
InsertVisible="False" ReadOnly="True"/>
</Columns>
</asp:GridView>

Now my handler:

protected void grdLista_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.ToolTip = e.Row.Cells[1].Text;
}
}


If I change e.Row.Cells[1].Text to something like "Hello", the HTML is rendered
fine, and the tooltip is inserted (<td title="hello">).

If I remove Visible="false" from BoundField, the description, GridView show the
description column and e.Row.Cells[1].Text returns the right description data.

If I put back Visible="false", the column is not rendered, but
e.Row.Cells[1].Text returns "".


How can I read something data-bounded, but not show in GridView and use it ?

Thanks in advance,

Fernando Monteiro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top