Using user controls in datagrids

Discussion in 'ASP .Net' started by =?Utf-8?B?TW9vampvbw==?=, Jul 8, 2005.

  1. I was wondering if anybody in this forum has tried the following:

    <edititemtemplate>
    <uc1:department_dropdown id="Department_dropdown2"
    runat="server"></uc1:department_dropdown>
    </edititemtemplate>

    This produces a dropdown and then when a user goes to update I have the
    following code.


    str_emp_dept =
    Convert.ToString(((DropDownList)e.Item.FindControl(Department_dropdown2.Selected_dept_value())));


    Howerver, I keep getting the following



    Server Error in '/WOW' Application.
    --------------------------------------------------------------------------------

    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information about
    the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set
    to an instance of an object.

    Source Error:

    Line 18: public string Selected_dept_value()
    Line 19: {
    Line 20: string dept_value = dept_dropdown.SelectedValue;
    Line 21: return dept_value;
    Line 22: }




    I know my user control works because I use it when inserting new names. Any
    help would be most helpful.
    --------------------------------------------------------------------------------
    Moojjoo Õ¿Õ


    http://www.mmwebs.com


    http://www.autoinventoryonline.com/
     
    =?Utf-8?B?TW9vampvbw==?=, Jul 8, 2005
    #1
    1. Advertising

  2. More infor:

    When debugging, I am watching the locals and it indicates
    Department_dropdown2 value = <undefined>

    I am a bit confused because when the page builds it does displays the
    correct values in the dropdown but will not get the values?

    I am scrathing my head on this one.

    "Moojjoo" wrote:

    > I was wondering if anybody in this forum has tried the following:
    >
    > <edititemtemplate>
    > <uc1:department_dropdown id="Department_dropdown2"
    > runat="server"></uc1:department_dropdown>
    > </edititemtemplate>
    >
    > This produces a dropdown and then when a user goes to update I have the
    > following code.
    >
    >
    > str_emp_dept =
    > Convert.ToString(((DropDownList)e.Item.FindControl(Department_dropdown2.Selected_dept_value())));
    >
    >
    > Howerver, I keep getting the following
    >
    >
    >
    > Server Error in '/WOW' Application.
    > --------------------------------------------------------------------------------
    >
    > Object reference not set to an instance of an object.
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information about
    > the error and where it originated in the code.
    >
    > Exception Details: System.NullReferenceException: Object reference not set
    > to an instance of an object.
    >
    > Source Error:
    >
    > Line 18: public string Selected_dept_value()
    > Line 19: {
    > Line 20: string dept_value = dept_dropdown.SelectedValue;
    > Line 21: return dept_value;
    > Line 22: }
    >
    >
    >
    >
    > I know my user control works because I use it when inserting new names. Any
    > help would be most helpful.
    > --------------------------------------------------------------------------------
    > Moojjoo Õ¿Õ
    >
    >
    > http://www.mmwebs.com
    >
    >
    > http://www.autoinventoryonline.com/
    >
     
    =?Utf-8?B?TW9vampvbw==?=, Jul 8, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?TW9vampvbw==?=

    Scott Allen Guest

    Hi Moojjoo:

    What control are you trying to find?

    I have a small article here that might help you understand what
    FindControl is doing:
    http://odetocode.com/Articles/116.aspx

    --
    Scott
    http://www.OdeToCode.com/blogs/scott/

    On Thu, 7 Jul 2005 19:18:02 -0700, "Moojjoo"
    <> wrote:

    >I was wondering if anybody in this forum has tried the following:
    >
    ><edititemtemplate>
    ><uc1:department_dropdown id="Department_dropdown2"
    >runat="server"></uc1:department_dropdown>
    ></edititemtemplate>
    >
    >This produces a dropdown and then when a user goes to update I have the
    >following code.
    >
    >
    >str_emp_dept =
    >Convert.ToString(((DropDownList)e.Item.FindControl(Department_dropdown2.Selected_dept_value())));
    >
    >
    >Howerver, I keep getting the following
    >
    >
    >
    >Server Error in '/WOW' Application.
    >--------------------------------------------------------------------------------
    >
    >Object reference not set to an instance of an object.
    >Description: An unhandled exception occurred during the execution of the
    >current web request. Please review the stack trace for more information about
    >the error and where it originated in the code.
    >
    >Exception Details: System.NullReferenceException: Object reference not set
    >to an instance of an object.
    >
    >Source Error:
    >
    >Line 18: public string Selected_dept_value()
    >Line 19: {
    >Line 20: string dept_value = dept_dropdown.SelectedValue;
    >Line 21: return dept_value;
    >Line 22: }
    >
    >
    >
    >
    >I know my user control works because I use it when inserting new names. Any
    >help would be most helpful.
    >--------------------------------------------------------------------------------
    >Moojjoo Õ¿Õ
    >
    >
    >http://www.mmwebs.com
    >
    >
    >http://www.autoinventoryonline.com/
     
    Scott Allen, Jul 8, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zi
    Replies:
    0
    Views:
    431
  2. Zi

    User Controls with in datagrids

    Zi, Oct 2, 2003, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    152
  3. Faizan Ahmed
    Replies:
    1
    Views:
    288
    John Saunders
    Jan 4, 2005
  4. Faizan Ahmed
    Replies:
    1
    Views:
    366
    John Saunders
    Jan 4, 2005
  5. Nicolaj

    Datagrids and User Controls

    Nicolaj, Jul 8, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    105
    Teemu Keiski
    Jul 10, 2006
Loading...

Share This Page