Results 1 to 4 of 4

Thread: [RESOLVED] [2005] Which event to use in GridView?

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Resolved [RESOLVED] [2005] Which event to use in GridView?

    Hi!
    I have a problem with the GridView

    When I put a row in edit mode by pressing the "Edit" button, in one of the templatecolumns I have a dropdownlist. If the source data returned to this dropdown is null (Its a list of contacts, and no contacts have been added), I need to add a row to this dropdown with text="No contacts available..." and value = -1, because -1 is returned from the Bind() of the gridview.

    Which event should I use to check the datasource for the edit dropdown? If the rows in teh datasource is 0 then I want to add this "dummy" row. But I need to do it before the grid is trying to bind, and after the data has been bound to the dropdown...

    This works great with the footer, when I hade the add item functonality. But there, the dropdown exist all the time... The edit dropdown exist only after the edit postback.
    Here is the code for the edit dropdown:

    Code:
    <EditItemTemplate>
                                            <asp:DropDownList ID="ddlEditVendorContact"
                                                                 runat="server"
                                                                 CssClass="text" 
                                                                 DataSource='<%# GetVendorContacts() %>'
                                                                 DataTextField="contact_name" 
                                                                 DataValueField="vendor_contact_id" 
                                                                 SelectedValue='<%# Bind("vendor_contact_id") %>'>
                                            </asp:DropDownList>
                                        </EditItemTemplate>
    Basically, if the GetVendorContacts() return table with 0 rows I need to add a dummy record BEFORE the SelectedValue='<%# Bind("vendor_contact_id") %>' occurs.

    Is this at all possible?

    kind regards
    Henrik
    Last edited by MrNorth; Jun 1st, 2007 at 03:21 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width