473,800 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to remove databinding programmaticall y?

I have several data sources that use the same gridView. I need to remove
columns from the gridview at run time where the DataBind.Eval statements dont
apply to the query currently using the grid.

I have discovered that using gridView.Column s.Remove(...) causes the
gridView OnRowCommand to quit functioning for any columns that remain in the
grid. (MS Please look into this, obviously a bug).

So Ive been looking at other ways to hide the columns without physically
removing them from the grid so that the OnRowCommand functionality works. All
is fine IF the column in question is a DataBound column. I simply set the
visibility = false and code executes with no problems

The issue arises when the column in the grid is a template field. Even if
the column is set to Visible = false, any DataBinder.Eval statements still
try to execute.

I can set the template column to Visible false, that great but I cannot find
away to programmaticall y remove the DataBind.Eval in the HTML. I tried at
least a dozen ways to access the control within the template, but I cannot
remove the eval statements even with . innerText

See below

<asp:TemplateFi eld HeaderText="Add ress">
<ItemTemplate >
<a id="linkMap" runat="server"
href="javascrip t:void(0)" onclick="LoadAd dress()">
<!--Remove all of the line below at run time-->
<%# FormatAddress(D ataBinder.Eval( Container.DataI tem, "addressAttenti on") %>
</a>
</ItemTemplate>
--
JP
..NET Software Developer

Aug 10 '07 #1
0 5026

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3871
by: Richard | last post by:
Hi, I have a DateTime picker control on a form. The datetime picker control is data bound to a column in a DataTable. Yes I know about bound DateTime pickers and DBNull and etc. so no troubles with that stuff... However, as somebody out there probably knows, programmatically setting the DateTimePicker.Value property to a new VALUE does NOT in itself constitute a CHANGE to
3
4609
by: Tzvika | last post by:
Hi, Is there a way to programmatically add/remove windows components in c# or in any other language What is the API fro that?
0
5430
by: Patrick B | last post by:
I'm wondering about the mechanics of databinding. Say that a textbox is bound to a property of a business object. The business object is a "Person". The control is a textbox called "ctlFirstName", and it's bound to the "FirstName" property of "Person". Why doesn't the following work? myForm.Show(); Person p = new Person();
4
1326
by: JV | last post by:
It's easy to databind a listbox or dropdownlist if all you want is to fill it with a list of values. There are plenty of examples in the online help. Unfortunately, real world applications demand more. Usually you would also like to bind the SelectedValue to something else. Common scenario: You have an ADDRESS table with a foreign key to a STATE table. You join on an integer or uniqueidentifier key value, but the STATE table is what...
1
1828
by: m_mohanna | last post by:
I've problem with databinding in vb.net The problem that i'm trying to set a text field of the databinding programmatically during runtime, the change appears on the form, but after save the new value is not saved to database, if i edit this field manually by the keyboard it is updated correctly. here's my code, the Q_ID textbox is the filed belongs to HEADERBindingSource binding source, i try to set it by the value of newQ_id, anyone can tell...
1
7323
by: Mark Stafford | last post by:
I am attempting to use a DetailsView control to view some data where the fields returned by the database are determined at runtime. I create the TemplateFields on the fly using a class that implements ITemplate and repopulate the Template properters of TemplateField in OnInit. And I am DataBinding by getting a DataTable from my db provider class in Page_Load event. When I databind programmatically in the Page_Load, the data displays in...
6
11138
by: AG | last post by:
I have a gridview with a template column containing an imagebutton to delete the row. Under some condition I don't want the row to be deleted, so would like to remove the button. In the RowDataBound event, I can find the button, but can't seem to remove it. The code below does not throw any exception, but the button is not removed. Protected Sub gv1_RowDataBound(ByVal sender As Object, ByVal e As
4
4700
by: Tor Inge Rislaa | last post by:
Databinding programmatically In my webform I have the code below in the form_load procedure. On the webform I have a GridView control. My question is simply how to bind the GridView to the datasource in the code programatically.
1
6891
by: Johnny Jörgensen | last post by:
I've got a combobox where the SelectedValue property is bound to a class property by a code like this: MyComboBox.DataBindings.Add("SelectedValue", MyClass , "MyID"); My problem is that the MyClass.MyID property gets updated when the focus leaves the combobox - not when you actually select a new item from the drdop down list. I would have expected this code to solve the problem, but it didn't:
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10504
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10251
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.