Subject: Re-assign the Control ID after Postback / Error
Posted By: AbrarNazeer Post Date: 6/20/2006 6:53:10 AM
 
 BackGround
     I have GridView with SqlDataSource to populate it. While I have Custom Search Control on my WebPage. When ever i click the srch btn to populate the grid its OK but when i put any srch data in any ctrl (e.g City = 'KHI' in city textbox) and then click the srch btn i suffered for the following msg

ERROR Message
====================================================================
An error has occurred because a control with id 'grdComplaints$ctl04$ctl00' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error.
====================================================================

 If any one has been faced and resolved such error then plz help me.
 Thanks for your time.


Reply By: jbenson001 Reply Date: 6/20/2006 10:18:37 PM
Can you post the code that calls your seach?  Is the searc a button you click.. is it in the grid..?  More info is needed.

Jim

Reply By: AbrarNazeer Reply Date: 6/21/2006 1:43:13 AM
 Search is my <asp:Button ID="btnSearch" runat="server" Text="Search" />
 it is not in the Grid.

btnSearch_Click
  does this
-------------------------------------------------------------------

             If Me.grdComplaints.Rows.Count = 0 Then
                lblErrorMsg.Text = "No Record Found."
                Me.pnlListComplaints.Visible = False
                Exit Try
             End if

-------------------------------------------------------------------


Reply By: jbenson001 Reply Date: 6/21/2006 10:09:08 AM
Is there somewhere that you are changing the ID of the grid, or other controls you create dynamically?

Reply By: AbrarNazeer Reply Date: 6/22/2006 12:51:58 AM

 Jim thanks for ur time.......
 ur qries and their answers are here below

 Qry#1. Is there somewhere that you are changing the ID of the grid
 Ans. NO

 Qry#2. or   other controls you create dynamically?
 Ans. NO

  


Reply By: roopesh Reply Date: 7/22/2006 7:53:36 AM
During postback your control ids might be getting changed. Check the page source to see whether the control id is as you want to be.

roopesh
Reply By: AbrarNazeer Reply Date: 7/22/2006 11:34:29 PM

 Thanks Roopesh !
         There was a mistake by me.GridView Control's EnableViewState Property was set to 'False' when i change it to 'True' it becomes functional.
       Once again thanks for ur time.


Go to topic 47231

Return to index page 450
Return to index page 449
Return to index page 448
Return to index page 447
Return to index page 446
Return to index page 445
Return to index page 444
Return to index page 443
Return to index page 442
Return to index page 441