Find a control using Cells(index).Controls(index)

Hi I have a datagrid with an edit, I also have validators on other parts of the page.

When I do an update on the page the validators are firing.

I need to disable them when updating. normally I could use Findcontrol, however the update linkbutton has no id. So i need to do something like this:

 

 

Sub dglinks_ItemCreated(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles dglinks.ItemCreated
   Dim x As LinkButton

		
   If e.Item.ItemType = ListItemType.EditItem Then
      x = CType(e.Item.Cells(2).Controls(0), LinkButton)
      x.CausesValidation = False
  End If
End Sub

 However I cannot get the proper control. i always get an out of range exception.

 

How can I get the proper cell and control numbers?

 

Thanks in advance


Gary
0
gbminnock
3/5/2008 11:20:08 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

7 Replies
932 Views

Similar Articles

[PageSpeed] 24

Why dont you simply add an ID to the link button


Vikram
www.vikramlakhotia.com


Please mark the answer if it helped you
0
vik20000in
3/5/2008 11:40:52 AM

Thats not possible. I dont create the link button. The datagrid does that. So I cant reference it.


Gary
0
gbminnock
3/5/2008 12:45:39 PM

Be sure that you have set the right index of the Cells in which your LinkButton reside... 


Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
3/5/2008 2:01:38 PM

Yes the question how do I find that index?


Gary
0
gbminnock
3/5/2008 2:26:34 PM

You can define the cells Index of the LinkButton to where it resides in your Grid Column.. if the LinkButton is in the first column of your Grid then you can have Cells(0) since the index starts with 0. 


Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
3/5/2008 2:32:31 PM

Yeah ok and it doesnt work for the update button. Also how do I get the index for the control?


Gary
0
gbminnock
3/5/2008 3:55:00 PM

If you are using Link Button then you can simply cast it to the sender like

     LinkButton lb = (LinkButton)sender;
     lb.CausesValidation = false;

 


Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
3/5/2008 4:03:09 PM
Reply:

Similar Artilces:

Finding a control using find control
Hi I am using ajax to load different User controls in a page . When I am using FindControl method to get the reference to the update panel in the main page (i have a master page where script manager list located, then i have my main page which uses the master page and it only contains an update panel and content template(where user controls gets loaded). Inside and event handler of my user cotrol i tried to access the update panel using page.findcontrol(< ID of the update panel>) i got a null value . but when i searched the control hierarchy of the page . i find it(using watch) i...

What control do I use (or do I not use a control at all...)
Okay so here's the story so far. I am making a blog to be incorporated into a website. Well, I'm doing the blog from scratch. I'm using MySQL to source all the data via MySQL .NET/Connector. Now while developing the script, I used DataReader and Response.Write to show the blog topics. Now that it has come to put it under a design (I'm using a Master Page for that), I've hit the problem. Response.Write shows all the topics before any of the design elements could be incorporated. So that (more or less) is out of question. So next I looked into the data presentation controls. I looked up GridVi...

GridView Cell Index and Control Index
How to find the grid view cell index and control index Where are you trying to do this from and what are you wanting to do?  Are you looking to find the cell index of a control inside of a gridviewrow?  ~Ben please can you  elaborate yr question in more detail... do you want selected rows index and cell or some selected control's row and cell index in gridview ?Thanx, [KaushaL] || BloG || Profile || Microsoft MVP"I would love to change the world, but they won’t give me the source code"Don't forget to click "Mark as Answer" on the post that helped yo...

How do I change the "z-index" of a panel control when using the dragpanel control to bring it to the front
I am using the dragpanel control to move images around on a webform, but I can't figure out how to dynamically change the z-index as I am dragging a control so that it comes to the front as it is being drug. Any help would be very much appreciated.  Hi, If you want to set z-index dynamically you can use Javascript.. I pasted a sample code     <script type="text/javascript">    function changeIndex(crl)    {    document.getElementById(crl).style.zIndex=-1;    }  &nbs...

How do I control one control from another control?
I have a page page1.aspx which is within a master page. On page I have a table with two cells. Within each cell I have placed two controls (ascx) that I have developed. Now I'd like to be able to get these two controls to interact. One needs to update the other. One has some search criteria that the other one needs to update its gridview. One needs to make the other visible/not visible at certain times. Out of the box neither control can see each other at all. Is there a good article or someplace I can find some information on how to do this?  AllAboutFocus.com. Information Technolo...

Custom Control within a Control Control
I am developing a custom controls that will render headers for different web sites. Within these controls, I want to place another custom control that will change the language. I created the language control and had it implement IPostBackDataHandler. This control works fine if I drag it on a new web form, but if I tell a header custom control to render it problems occur. The Language Selector custom control does not have a Page member anymore and the event handlers do not work. Does anyone have any experience with doing something similiar? Anyone have any suggestions? Thanks, ...

Page and Control Flashing Using AJAX Control Toolkit Controls
Page and Control Flashing Using AJAX Control Toolkit Controls I'm using IE7 and the ASP.NET AJAX Control Toolkit.  I'm using two controls -- Accordion and CollapsiblePanelExtender.  I'm actually using 2 CollapsiblePanelExtenders, and the Accordion control is inside one of the panels for the CollapsiblePanelExtender (see the code below). The problem I'm seeing is that when I click an Accordion pane to open/close it or click the CollapsiblePanelExtender panel to open/close the panels, the controls and page flash while the animation is in progess.  Everything el...

Ajax Control Toolkit: Control cannot be created because Visual Studio cannot find the control's type in the control assembly.
Hi All, Good Day.  I am using ASP.Net 2.0 Framework, i have downloaded Ajax 3.0 and added reference into the project. But i am not able to add controls to the page. When i tried to add control into the page getting following error message "Control cannot be created because Visual Studio cannot find the control's type in the control assembly". I checked some forums on the web, added references in Web.Config. Still not able to proceed further. Please revert asap.  Thanks. AJAX 3.0 not work in 2.0 Framework its work in 3.5 Framework try to download another ...

Cascading Dropdown error in formview controls and finding all controls in formview controls
can help with the following? Instantiate Cascading Dropdowns within Formview controls (this returns the error message "databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control".) Pass values between controls within master controls such as Textboxes within formviews (example: Pass the selected value in a dropdownlist to another textbox both WITHIN a formview control) Expose the public properties of a master page Hi arraybiz, 1) I need your code. See sample: http://www.mikepope.com/blog/fun/cascadingdropdowns_dy...

Control cannot be cretaed because Visual Studio cannot find the controls type in the control assembly
This is a possible IDE bug please do the following to replicate 1.Create a new Web application 2.Create a new class library project called ClassLibrary1 3.Create a new WEbCustom control in ClassLibrary1 called WebCustomControl1 4.Create a new class library project called ClassLibrary2 5.Create a bummy interface called interface1 in ClassLibrary2 6.Implement interface1 by WebCustomControl1 7.complile solution 8.Add the WebCustomControl1 to the toolbox and try to added to a page of the Web application the message of the subject appears is there a way to overcome this ? am i missing ...

control cannot be created because Visual Studio Cannot find the Controls type in the Control Assembly
Hi Friends, I have installed Visual Studion 2005 on my machine. After creating an AJAX FutureRelese Web project. I tried to add Future Release Controls to my web page. I am getting the following error "control cannot be created because Visual Studio Cannot find the Controls type in the Control Assembly" Could you please get back to me with the solution for this. Thanks and Regards, Baburaj P V Pls make sure you have System.Web.Extensions referenced. If Not Add it from the Reference Dialog, it is insalled in the GAC. If you also have the previous version then you have to modify th...

control cannot be created because visual studio find the controls type in the control assembly
Hi to all,            I'm working with Asp.Net2.0,VS2005-C# and Crystal Report 11.5.            Whenever i drag and drop the CrystalReportViewer control from Toolbox then i got this error control cannot be created because visual studio find the controls type in the control assembly then i click OK button then it display one more error Invalid Forematetc structure (Exception from HRESULT: 0x80040064(DV_E_FORMATETC) But all other projects i can add the control from toolbox&nb...

Trying to use the FAQ " Sorting and paging in the GridView control when not using data source controls "Sorting and paging in the GridView control when not using..."
and I am not getting the results I had hoped for.  I keep getting a "Compiler Error Message: CS0123: No overload for 'AdhocJobGridView_PageIndexChanged' matches delegate 'System.EventHandler'".   Here is my event handling... protected void AdhocJobGridView_PageIndexChanged(object sender, GridViewPageEventArgs e){ try { AdhocJobGridView.DataSource = wsBaseInfoArray; AdhocJobGridView.PageIndex = e.NewPageIndex; AdhocJobGridView.DataBind(); }catch (Exception ex) {throw ex; }   Here is my aspx... <asp:GridView ID="AdhocJobGridView...

How to use FindControl to find a Control within another Control?.....
I am working with a MultiView on one of my aspx pages and have an interesting situation. I have placed a gridview within one of the Views, but I have customized the template to use text labels as titles and text boxes to display the information for updating puposes and flow. I have included an "UpdateButton" calling an update stored proceedureI know how to find controls embeded within a single level ie..Dim Gridview2 As GridView = DirectCast(Me.MultiView1.FindControl("GridView2"), GridView)But within the GridViews I have to access the TextBox's ie the code belowD...

Web resources about - Find a control using Cells(index).Controls(index) - asp.net.presentation-controls

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Venezuela's Opposition Wins Control of Legislature - Al Jazeera America
The opposition won at least 99 seats in Venezuela's 167-seat legislature, in a major setback for President Nicolas Maduro

The ACLU backs using the terror watch list for gun control, but only “with major reform”
... did say, through a spokesperson, that the watch list would need “major reforms” in order to be used as an effective tool for gun control and ...

With gun control off-limits, politicians want tech sector to fight terror
... very next day, the Senate voted against a measure that would have barred gun sales to people on federal terror watchlists. Another gun-control ...

Obama calls for better gun control, and for tech companies to help fight terrorism
President Barack Obama all but called out encryption in a 15-minute Address to the Nation speech on Sunday night. The President touched on various ...

Obama speaks on ISIS, gun control, tolerance in Oval Office address - Videos - CBS News
In a primetime speech Sunday night, President Obama said the terror attack in San Bernardino, California, shows terrorism is now in a new phase. ...

Sugr Cube is a Sweet Spotify Speaker with Touch & Motion Control
... goodies, like Spotify Connect, Pandora, and, eventually, Air Play integration. Sugr also had a little bit of fun with volume and track controls ...

Windows 10 vs. OS X: Which gives sys admins more control?
Nearly everything can be managed as if it were a mobile device, using APIs at the operating system for assured reach and consistent implementation ...

NV's Fiore: 'That 5 Year Old Grandson Of Mine Has Total Trigger Control'
It's very likely you've seen Michele Fiore's family Christmas photo by now, it's been all the rage at Idiocracy viewing parties everywhere. If ...

The Solution Isn’t As Simple As Gun Control
... latest column over at the Daily Beast details how, in the wake of the San Bernardino shootings, Democrats were quick to pounce on the gun control ...

Resources last updated: 12/9/2015 3:28:32 AM