locked
Gridview find a textbox by controlID RRS feed

  • Question

  • User363578564 posted

    The Gridview is filtered by the following parameters in a textbox OUT of the GV.  It is OK

    <FilterParameters>
                <asp:ControlParameter Name="EventName" ControlID="TxtFilter" PropertyName="Text" />
    </FilterParameters><filterparameters> <asp:controlparameter name="EventName" propertyname="Text" controlid="TxtFilter"></asp:controlparameter> </filterparameters>

    Now the textbox is moved IN the header of the GV.

    i try to change the ControlID of FilterParamters, it seems not OK

    ControlID='<%# GV_Enrollments.HeaderRow.FindControl("TxtFilter").ClientID %>'

    Any ideas.  Thanks a lot.

    Thursday, August 9, 2018 2:21 AM

Answers

  • User283571144 posted

    Hi TW88,

    In my opinion, this is the right.

    If you put the search textbox in side the girdview, it will return not found error, since the gridview is generated according to the datasource.

    It couldn't find the textbox since it doesn't generated when databind.

    Here is a workaround, I suggest you could put the textbox ouside the girdview.

    Then you could generate the table's header by using html and css without directly putting the textbox in the girdview.

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 10, 2018 9:20 AM

All replies

  • User283571144 posted

    Hi TW88,

    In my opinion, this is the right.

    If you put the search textbox in side the girdview, it will return not found error, since the gridview is generated according to the datasource.

    It couldn't find the textbox since it doesn't generated when databind.

    Here is a workaround, I suggest you could put the textbox ouside the girdview.

    Then you could generate the table's header by using html and css without directly putting the textbox in the girdview.

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 10, 2018 9:20 AM
  • User363578564 posted

    Thanks a lot for your advice.

    I made a logic mistake.  I never saw such design. 

    at last, I put it out of the GV

    Friday, August 10, 2018 9:39 AM