Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8225469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:25:43+00:00 2026-06-07T15:25:43+00:00

I am writing asp.net project in C# and I have a litle problem. I

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:25:44+00:00Added an answer on June 7, 2026 at 3:25 pm

    I would do that from GridView’s RowDataBound event which is triggered for every GridViewRow but only when the GridView gets databound.

    protected void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
    {
        var grid = (GridView)sender;
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DropDownList DropDownList1 = (DropDownList)e.Row.FindControl("DropDownList1");
            DataRowView drv = (DataRowView)e.Row.DataItem;
            DataSet ds = drv.Row.Table.DataSet;
            // i'm not 100% sure what you need here, for example:
            DropDownList1.ToolTip = drv.Row.Field<int>("p_id").ToString();
        }
    }
    

    This is much more readable and easier to maintain and debug.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multi-project ASP.NET + C# solution. I was planning on writing a
I'm writing am ASP.NET/C# project, it's a simple blog page with commnents. Problem I'm
I'm writing a project in c# asp.net mvc3, and I have a helper-class that
I am writing a learning project in ASP.NET MVC. I have a page Books
I'm currently writing a project in ASP.NET MVC. I have a web project and
While writing an asp.net project i may have this url for testing/debugging http://localhost:1234/ I
I am writing asp.net project in C#. I have a button in a page
I have an external JavaScript in an asp.net 3.5 project. While writing different functions,
I have ASP.NET MVC3 project and I am writing some extension methods that returns
I'm writing service which will use for sending emails in my ASP.NET project. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.