I am having a hard time with this one, and I thought it would be easy.
I have a datagrid in which I have textboxs for users to enter data. One of
the fields in the database behind the datagrid tells me if the textbox is
readonly or not. I am having a hard time setting the readonly property of the
textbox with a conditional if statement (IIF).
Here is the coding;
<asp:TemplateCo lumn HeaderText="Dat a Entry">
<ItemTemplate >
<img src="images/Barrow.gif" onclick="CopyTo tal(this);" title="Click here to
copy Previous Field to this text box">
<asp:TextBox CssClass="print ableTextbox" runat="server"
onchange="AddRe questerName(thi s);" Readonly='<% #
iif(Container.D ataItem("NotAll owed")=1,True,F alse) %>' id="txtDataEntr y"
Text='<% # Format(Containe r.DataItem("Dat a"),"$#,##0.00" ) %>'
onblur="this.va lue=FormatCurre ncy(this.value, 1);">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateCol umn>
What am I doing wrong with the readonly? If I look at the source, it isn't
being produced within the page.
Thank you,
Lyners 3 4091
There is nothing wrong with the way you used IIF. You can check the outcome
on this link: http://www.societopia.net/samples/dataGrid_5.aspx
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"Lyners" wrote: I am having a hard time with this one, and I thought it would be easy.
I have a datagrid in which I have textboxs for users to enter data. One of the fields in the database behind the datagrid tells me if the textbox is readonly or not. I am having a hard time setting the readonly property of the textbox with a conditional if statement (IIF).
Here is the coding; <asp:TemplateCo lumn HeaderText="Dat a Entry"> <ItemTemplate > <img src="images/Barrow.gif" onclick="CopyTo tal(this);" title="Click here to copy Previous Field to this text box"> <asp:TextBox CssClass="print ableTextbox" runat="server" onchange="AddRe questerName(thi s);" Readonly='<% # iif(Container.D ataItem("NotAll owed")=1,True,F alse) %>' id="txtDataEntr y" Text='<% # Format(Containe r.DataItem("Dat a"),"$#,##0.00" ) %>' onblur="this.va lue=FormatCurre ncy(this.value, 1);"> </asp:TextBox> </ItemTemplate> </asp:TemplateCol umn>
What am I doing wrong with the readonly? If I look at the source, it isn't being produced within the page.
Thank you, Lyners
probably the IIF statement always returns false... you may want to give it a
try changing it to a function similar to below.. this will help debugging the
condition..
<asp:TextBox ReadOnly='<%#Ch eckReadOnly(Dat aBinder.Eval(Co ntainer.DataIte m,
"NotAllowed").T oString())%>' ID="Text1" ></asp:TextBox>
in code behind ..
protected bool CheckReadOnly(s tring val)
{
if(val == "1")
return(true);
else
return(false);
}
"Lyners" wrote: I am having a hard time with this one, and I thought it would be easy.
I have a datagrid in which I have textboxs for users to enter data. One of the fields in the database behind the datagrid tells me if the textbox is readonly or not. I am having a hard time setting the readonly property of the textbox with a conditional if statement (IIF).
Here is the coding; <asp:TemplateCo lumn HeaderText="Dat a Entry"> <ItemTemplate > <img src="images/Barrow.gif" onclick="CopyTo tal(this);" title="Click here to copy Previous Field to this text box"> <asp:TextBox CssClass="print ableTextbox" runat="server" onchange="AddRe questerName(thi s);" Readonly='<% # iif(Container.D ataItem("NotAll owed")=1,True,F alse) %>' id="txtDataEntr y" Text='<% # Format(Containe r.DataItem("Dat a"),"$#,##0.00" ) %>' onblur="this.va lue=FormatCurre ncy(this.value, 1);"> </asp:TextBox> </ItemTemplate> </asp:TemplateCol umn>
What am I doing wrong with the readonly? If I look at the source, it isn't being produced within the page.
Thank you, Lyners
Yes, I just had to step through it to see what the data was sending back. i
had the field defined as bit, and because so it was already true or false. I
just needed to read the field... no iif, or anything else.
Thanks.
"Sreejith Ram" wrote: probably the IIF statement always returns false... you may want to give it a try changing it to a function similar to below.. this will help debugging the condition..
<asp:TextBox ReadOnly='<%#Ch eckReadOnly(Dat aBinder.Eval(Co ntainer.DataIte m, "NotAllowed").T oString())%>' ID="Text1" ></asp:TextBox>
in code behind .. protected bool CheckReadOnly(s tring val) { if(val == "1") return(true); else return(false);
}
"Lyners" wrote:
I am having a hard time with this one, and I thought it would be easy.
I have a datagrid in which I have textboxs for users to enter data. One of the fields in the database behind the datagrid tells me if the textbox is readonly or not. I am having a hard time setting the readonly property of the textbox with a conditional if statement (IIF).
Here is the coding; <asp:TemplateCo lumn HeaderText="Dat a Entry"> <ItemTemplate > <img src="images/Barrow.gif" onclick="CopyTo tal(this);" title="Click here to copy Previous Field to this text box"> <asp:TextBox CssClass="print ableTextbox" runat="server" onchange="AddRe questerName(thi s);" Readonly='<% # iif(Container.D ataItem("NotAll owed")=1,True,F alse) %>' id="txtDataEntr y" Text='<% # Format(Containe r.DataItem("Dat a"),"$#,##0.00" ) %>' onblur="this.va lue=FormatCurre ncy(this.value, 1);"> </asp:TextBox> </ItemTemplate> </asp:TemplateCol umn>
What am I doing wrong with the readonly? If I look at the source, it isn't being produced within the page.
Thank you, Lyners This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paulo Gon?alves via .NET 247 |
last post by:
My datagrid has a big problem, it happens only in columns that are read only.
Please see the picture at
http://mega.ist.utl.pt/~pfrg/datagrid/datagrid_problem.jpg
The gost that I show it?s like a new readonly textbox.
If the selected cell it?s not readonly there?s no problem.
I think that the problem it?s ralated with lose of focus of the datagrid.
After pressing a button, I fill again the datagrid with new datasource but this thing...
|
by: GP |
last post by:
Is it possible to iterate through all the controls collection and make the
textboxes alone as read only.I don't see a readonly property for the
Control.Can some one help me in this context?
I want to do something like this below.But I get a message Readonly is not
valid property.
foreach (Control ctl in pnlBenefits.Controls)
{
if (ctl is TextBox)
ctl.ReadOnly=false;
}
|
by: Dany P. Wu |
last post by:
Hi everyone,
I'm not entirely sure if this is the best way of going about it, but here's
the scenario..........
I have two datagrid, each bound to a datatable which have checkbox columns.
There are two buttons between the datagrids, "Add" and "Remove". They
basically remove rows from one grid to the other, only those with the
checkbox ticked.
|
by: Doug Bell |
last post by:
Hi,
I needed to make a TextBox on a DataGrid ReadOnly based on the condition of
another cell on its row.
I achieved this using a Custom Data Column Class "DacDGTextColLotNo" but I
can't get the TextBox to display its value when you leave the TextBox.
I figure that I need to use the SetColumnValueAtRow Method but I am
struggling to understand how.
|
by: Tricia Colwell via DotNetMonster.com |
last post by:
Here is what i have:
I have a datagrid with two columns one is a combo box style and the other
is a textbox style. If the combo box is "Between" or "Like" i want that the
next cell to be readonly..which is the textbox one.
How do i do this???
Tricia
--
| |
by: John Smith |
last post by:
Hi All;
I am using the HeaderAndDataAlignColumn class from Ken Tucker. I have
customized it for a wider row. I reposition the DrawString method so the
text is centered vertically in the row.
My problem now is that on ReadOnly cells the shaded background is not at the
top of the cell. I adjust the rectangle Height so that the shading does not
drop into the next row.
|
by: John Smith |
last post by:
Is it possible to set DataGrid's ReadOnly property to True/False at runtime?
An example:
<asp:datagrid id="dg1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="id" ReadOnly="True"
HeaderText="ID"></asp:BoundColumn>
</Columns>
<asp:datagrid>
|
by: Hamed |
last post by:
Hello
I have a DataGrid object in my ASP.NET page that has the following template
column. When I put the "readonly" attribute in the INPUT tag, it generates
readonly="".
<asp:TemplateColumn HeaderText="Kg Price" HeaderStyle-Width="5%">
<ItemTemplate><INPUT class="ep" id=kf readOnly value='<%#
DataBinder.Eval(Container, "DataItem.KgFee") %>' name=kf
runat="server"></ItemTemplate>
|
by: RolfHerbert |
last post by:
Hi all,
Source code below. I am using an sqldatasorce to populate a datagrid.
I am using datakeyIds.
I am interested in two keys which I have added to the datakeyids,
however if either of the keys is not databound, set to visible=false
or readonly=true, they are unavailable as parameters in my update
statement.
|
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: 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...
| |
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: 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: 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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |