I am writing asp.net project in C# and I have a litle problem.
I have a dropdownlist inside gridview and both of them initially is filled from one database but different tables(different select queries).
I want to set ToolTip for dropdownlist from query which is used to fill gridview(DataTable1) by following code:
<asp:TemplateField HeaderText="choose supervisor" ItemStyle-Width="100px">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddlTest_SelectedIndexChanged"
ToolTip =<%#((DataSet1.DataTable1Row)(((DataRowView)Container.DataItem).Row)).p_id %>>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
but when I try run the project I get the following error:
Object reference not set to an instance of an object.
If I try set Tooltip manually, for example:
ToolTip = "abc"
the project runs without any problem.
Does someone know how to set tooltip for dropdownlist from database query?
Thanks.
I would do that from GridView’s
RowDataBoundevent which is triggered for everyGridViewRowbut only when theGridViewgets databound.This is much more readable and easier to maintain and debug.