I'm doing an inline edit of an Admin table using the
Datagrid. There are three columns in my Admin table. I
want to dynamically disable the corresponding "CareType"
field (see below) in the grid if the record is part of an
existing relationship, so the user can't update it.
The "CareTypeID " field is the key and is invisible to the
user.
Here is the db table columns:
CareTypeID
CareType
CareTypeDesc
Here is my code in the DataGrid1.EditC ommand event:
<code>
Dim intRecdsFnd As Integer
intRecdsFnd = ValidateChild.V alidateChildTab le
("CallType", DataGrid1.DataK eys(e.Item.Item Index), CType
(Application("s trDataSource"), String))
Dim txtCareType As TextBox = DirectCast
(e.Item.FindCon trol("txtCareTy pe"), TextBox)
If intRecdsFnd = 0 Then
txtCareType.Ena bled = True
Else
txtCareType.Ena bled = False
End If
ViewState.Item( "intRecdsFn d") = Convert.ToInt32
(intRecdsFnd)
DataGrid1.EditI temIndex = e.Item.ItemInde x
BindData()
</code>
When executing the following line above in order to
disable the field that I want,
<code>
Dim txtCareType As TextBox = DirectCast(e.It em.FindControl
("txtCareType") , TextBox)
</code>
the value comes back as "Nothing"!
Here is my corresponding code in the HTML of the aspx page
for the column:
<code>
<asp:TemplateCo lumn HeaderText="Car eType">
<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval
(Container, "DataItem.CareT ype") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:TextBox id="txtFtrCareT ype" Columns="20"
runat="server" MaxLength="30"> </asp:TextBox>
</FooterTemplate>
<EditItemTempla te>
<asp:TextBox id=txtCareType Columns="20"
runat="server" MaxLength="20" Text='<%# DataBinder.Eval
(Container, "DataItem.CareT ype") %>'>
</asp:TextBox>
<asp:RequiredFi eldValidator
id="Requiredfie ldvalidator1" runat="server"
ControlToValida te="txtCareType " ErrorMessage="C areType is
required!"
CssClass="inval id" Font-Bold="True" />
</EditItemTemplat e>
</asp:TemplateCol umn>
</code>
Just to see, I get a hit if I use an ID value for the
Label in the ItemTemplate, but I don't get a hit when
trying to get the value from the EditItemTemplat e.
However, the Label value doesn't do me any good, since I
need to disable the field when the user presses the Edit
command.
I tried moving the following line:
<code>
Dim txtCareType As TextBox = DirectCast(e.It em.FindControl
("txtCareType") , TextBox)
</code>
after the BindData() routine (which executes the
DataGrid1.ItemD ataBound event), but still didn't help.
How come I am not getting a hit on the ID value of the
textbox during the EditCommand? 1 1687
I solved the problem by moving the code into the
ItemDataBound event like so:
[ code ]
If e.Item.ItemType = ListItemType.Ed itItem Then 'Check
whether or not to enable the CareType
Dim intRecdsFnd As Integer
intRecdsFnd =
ValidateChild.V alidateChildTab le("CallType",
DataGrid1.DataK eys(e.Item.Item Index), CType(Applicati on
("strDataSource "), String))
Dim txtCareType As TextBox = DirectCast
(e.Item.FindCon trol("txtCareTy pe"), TextBox)
If intRecdsFnd = 0 Then
txtCareType.Ena bled = True
Else
txtCareType.Ena bled = False
End If
End If
[ / code ] -----Original Message----- I'm doing an inline edit of an Admin table using the Datagrid. There are three columns in my Admin table. I want to dynamically disable the corresponding "CareType" field (see below) in the grid if the record is part of an existing relationship, so the user can't update it. The "CareTypeID " field is the key and is invisible to the user.
Here is the db table columns: CareTypeID CareType CareTypeDesc
Here is my code in the DataGrid1.EditC ommand event: <code> Dim intRecdsFnd As Integer intRecdsFnd = ValidateChild.V alidateChildTab le ("CallType", DataGrid1.DataK eys(e.Item.Item Index), CType (Application(" strDataSource") , String)) Dim txtCareType As TextBox = DirectCast (e.Item.FindCo ntrol("txtCareT ype"), TextBox) If intRecdsFnd = 0 Then txtCareType.Ena bled = True Else txtCareType.Ena bled = False End If ViewState.Item( "intRecdsFn d") =
Convert.ToInt32(intRecdsFnd ) DataGrid1.EditI temIndex = e.Item.ItemInde x BindData() </code>
When executing the following line above in order to disable the field that I want, <code> Dim txtCareType As TextBox = DirectCast(e.It em.FindControl ("txtCareType" ), TextBox) </code> the value comes back as "Nothing"!
Here is my corresponding code in the HTML of the aspx
pagefor the column: <code> <asp:TemplateC olumn HeaderText="Car eType">
<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container, "DataItem.CareT ype") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate >
<asp:TextBox id="txtFtrCareT ype" Columns="20" runat="serve r" MaxLength="30"> </asp:TextBox>
</FooterTemplate>
<EditItemTempla te>
<asp:TextBox id=txtCareType Columns="20" runat="serve r" MaxLength="20" Text='<%# DataBinder.Eval (Container, "DataItem.CareT ype") %>'>
</asp:TextBox>
<asp:RequiredFi eldValidator id="Requiredfi eldvalidator1" runat="server" ControlToValid ate="txtCareTyp e" ErrorMessage="C areType is required!"
CssClass="inval id" Font-Bold="True" />
</EditItemTemplat e>
</asp:TemplateCol umn> </code>
Just to see, I get a hit if I use an ID value for the Label in the ItemTemplate, but I don't get a hit when trying to get the value from the EditItemTemplat e. However, the Label value doesn't do me any good, since I need to disable the field when the user presses the Edit command.
I tried moving the following line: <code> Dim txtCareType As TextBox = DirectCast(e.It em.FindControl ("txtCareType" ), TextBox) </code>
after the BindData() routine (which executes the DataGrid1.Item DataBound event), but still didn't help.
How come I am not getting a hit on the ID value of the textbox during the EditCommand? . This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Richard Roche |
last post by:
Is it possible to use a drop combo instead of a text box
when using the EditCommand in the Datagrid? Many table
columns are bound to 'lookup' tables, user's don't care
about the foreign keys, they want the text value. Any
advice, samples or places to read are appreciated.
Thanks.
|
by: Chad Folden |
last post by:
I can't figure out how to use the EditCommand for the
nested datagrid .. HELP PLEASE ;-) It works perfectly for
the parent datagrid, but will not display, even though the
EditCommand event is firing for the child datagrid. I
have set up a test page for myself to see if I can get
this to work ..any help is appreciated! Thanks in advance
(This is my complete page and code behind)
<asp:DataGrid ID="_dgProj" AllowPaging=False
|
by: Dan C Douglas |
last post by:
I have created a hierarchical datagrid that consists of 1 datagrid nested insde of another datagrid. More technically it is actually 1 User control that contains a datagrid. I add this user control to each iteration of the Item_DataBound event, and therefore the same user control gets added to itself. It works perfectly for displaying the data.
The problem is when I click the edit button in a second level item in the datgrid (sub user...
|
by: Mike |
last post by:
I've got an app with a DataTable that gets passed around and modified
by datagrids on 3 different asp.net pages. Not all columns need to be
displayed, but I need them all in the datagrid so I can call the
LoadDataRow method to update the DataTable "in place".
I've been using boundcolumns for the invisible fields, which worked
fine, but now I've run into an issue with them. On the second of the
3 pages, the user can modify certain...
|
by: localhost |
last post by:
A DataGrid with shows a label in one of the columns when
in view mode. When in edit mode, I want to show a
dropdown, and have the default selection set to what the
textbox used to be. Right now the first item in the
dropdown is always displayed.
Template Code:
<asp:TemplateColumn HeaderText="DropDown">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval
| |
by: Rick |
last post by:
Hello all, I hope all is well with you.
I am having a seriously difficult time with this problem. Allow me to
set
up the problem.
I have a System.Web.UI.Page with the following controls (watch the
layout,
some have child controls):
|
by: tshad |
last post by:
I am having trouble with links in my DataGrid.
I have Links all over my page set to smaller and they are consistant all
over the page in both Mozilla and IE, except for the DataGrid.
Here is a snippet from my .css file:
***************************
body {
margin:0;
padding:0;
|
by: MrMike |
last post by:
I have a sub named Bind("") which binds my a datagrid on my webform. In
order to enter edit mode and edit records on this datagrid, I must make a
call to Bind("") either before or after I place the DataGrid into edit mode.
For example, DataGrid.EditCommand looks like this ...
DataGrid1.EditItemIndex = e.Item.ItemIndex
Bind("")
Without having the Bind("") call within the EditCommand, an exception occurs
saying something to the extent...
|
by: Tina |
last post by:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing
validation elsewhere on the page. I want to specify that these buttons
should not cause validation but they have no design time property of
causevalidation.
How can I keep them from causing validation?
Thanks,
T
|
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...
|
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,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |