Hi all,
Iam binding a datatable with the data grid, In the data table
there is a column as Posted_flag char(1), which can have value either N
or Y .
My issue is that in my grid there is a an
item template with a checkbox control, depending upon the value, Y or N
it should show checked or unchecked.
What should i do for this ?
Thanks in Advance
Thomson 5 3171
Hi Thomson,
You can use an IIF() function to test the incoming value of Posted_flag and
then let it check or uncheck the box. Here's some code:
<asp:templatecolumn HeaderText="Y/N">
<itemtemplate>
<asp:checkbox id="Checkbox2" runat="server" Checked='<%#
IIF(Container.DataItem("Posted_flag")="Y","true"," false") %>' >
</asp:checkbox>
</itemtemplate>
</asp:templatecolumn>
Let us know if this helps?
Ken
Microsoft MVP [ASP.NET]
"thomson" <sa**********@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com... Hi all, Iam binding a datatable with the data grid, In the data table there is a column as Posted_flag char(1), which can have value either N or Y . My issue is that in my grid there is a an item template with a checkbox control, depending upon the value, Y or N it should show checked or unchecked. What should i do for this ?
Thanks in Advance
Thomson
Hi KEn
Line 136: <HEADERSTYLE VerticalAlign="Top"
HorizontalAlign="Center" Wrap="False"></HEADERSTYLE>
Line 137: <ITEMTEMPLATE>
Line 138: <asp:CheckBox ID="chkPosted" Runat="server"
checked='<%# IIF(Container.DataItem("Posted_Flag")=="Y","true", "false")
%>' ></asp:CheckBox>
Line 139: </ITEMTEMPLATE>
Line 140: <EDITITEMTEMPLATE>
Source File: c:\inetpub\wwwroot\finance\FINANCE\TransactionPost ing.aspx
Line: 138
Show Detailed Compiler Output:
CMicrosoft (R) Visual C# .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
c:\inetpub\wwwroot\finance\FINANCE\TransactionPost ing.aspx(138,52):
error CS0118: 'System.Web.UI.WebControls.DataGridItem.DataItem' denotes
a 'property' where a 'method' was expected
c:\inetpub\wwwroot\finance\FINANCE\TransactionPost ing.aspx(138,38):
error CS0103: The name 'IIF' does not exist in the class or namespace
'ASP.TransactionPosting_aspx'
What might be the problem?
Regards
thomson
Ken Cox [Microsoft MVP] wrote: Hi Thomson,
You can use an IIF() function to test the incoming value of
Posted_flag and then let it check or uncheck the box. Here's some code:
<asp:templatecolumn HeaderText="Y/N"> <itemtemplate> <asp:checkbox id="Checkbox2" runat="server"
Checked='<%# IIF(Container.DataItem("Posted_flag")="Y","true"," false") %>' > </asp:checkbox> </itemtemplate> </asp:templatecolumn>
Let us know if this helps?
Ken Microsoft MVP [ASP.NET]
"thomson" <sa**********@yahoo.com> wrote in message news:11**********************@c13g2000cwb.googlegr oups.com... Hi all, Iam binding a datatable with the data grid, In the data table there is a column as Posted_flag char(1), which can have value
either N or Y . My issue is that in my grid there is a an item template with a checkbox control, depending upon the value, Y
or N it should show checked or unchecked. What should i do for this ?
Thanks in Advance
Thomson
Hi ken
i got something like this
Line 1922: #line 138
"c:\inetpub\wwwroot\finance\FINANCE\TransactionPos ting.aspx"
Line 1923: target.Checked =
((bool)(DataBinder.Eval(Container,"DataItem.Posted _Flag")=="Y" ? True :
False));
Line 1924:
Line 1925: #line default
Line 1926: #line hidden
Line 1927: }
in the complete compilation source
and it says
CS0103: The name 'True' does not exist in the class or namespace
'ASP.TransactionPosting_aspx'
Help me out
Regards
thomson
thomson wrote: Hi KEn
Line 136: <HEADERSTYLE VerticalAlign="Top" HorizontalAlign="Center" Wrap="False"></HEADERSTYLE> Line 137: <ITEMTEMPLATE> Line 138: <asp:CheckBox ID="chkPosted" Runat="server" checked='<%#
IIF(Container.DataItem("Posted_Flag")=="Y","true", "false") %>' ></asp:CheckBox> Line 139: </ITEMTEMPLATE> Line 140: <EDITITEMTEMPLATE>
Source File:
c:\inetpub\wwwroot\finance\FINANCE\TransactionPost ing.aspx Line: 138 Show Detailed Compiler Output:
CMicrosoft (R) Visual C# .NET Compiler version 7.10.6001.4 for Microsoft (R) .NET Framework version 1.1.4322 Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
c:\inetpub\wwwroot\finance\FINANCE\TransactionPost ing.aspx(138,52): error CS0118: 'System.Web.UI.WebControls.DataGridItem.DataItem'
denotes a 'property' where a 'method' was expected c:\inetpub\wwwroot\finance\FINANCE\TransactionPost ing.aspx(138,38): error CS0103: The name 'IIF' does not exist in the class or namespace 'ASP.TransactionPosting_aspx'
What might be the problem? Regards
thomson
Ken Cox [Microsoft MVP] wrote: Hi Thomson,
You can use an IIF() function to test the incoming value of Posted_flag and then let it check or uncheck the box. Here's some code:
<asp:templatecolumn HeaderText="Y/N"> <itemtemplate> <asp:checkbox id="Checkbox2" runat="server" Checked='<%# IIF(Container.DataItem("Posted_flag")="Y","true"," false") %>' > </asp:checkbox> </itemtemplate> </asp:templatecolumn>
Let us know if this helps?
Ken Microsoft MVP [ASP.NET]
"thomson" <sa**********@yahoo.com> wrote in message news:11**********************@c13g2000cwb.googlegr oups.com... Hi all, Iam binding a datatable with the data grid, In the data table there is a column as Posted_flag char(1), which can have value either N or Y . My issue is that in my grid there is a an item template with a checkbox control, depending upon the value,
Y or N it should show checked or unchecked. What should i do for this ?
Thanks in Advance
Thomson
Oh. You didn't say you were using C#. IIF is a VB thing. Need to find the
comparable C# syntax.
"thomson" <sa**********@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com... Hi KEn
Line 136: <HEADERSTYLE VerticalAlign="Top" HorizontalAlign="Center" Wrap="False"></HEADERSTYLE> Line 137: <ITEMTEMPLATE> Line 138: <asp:CheckBox ID="chkPosted" Runat="server" checked='<%# IIF(Container.DataItem("Posted_Flag")=="Y","true", "false") %>' ></asp:CheckBox> Line 139: </ITEMTEMPLATE> Line 140: <EDITITEMTEMPLATE>
Source File: c:\inetpub\wwwroot\finance\FINANCE\TransactionPost ing.aspx Line: 138 Show Detailed Compiler Output:
CMicrosoft (R) Visual C# .NET Compiler version 7.10.6001.4 for Microsoft (R) .NET Framework version 1.1.4322 Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
c:\inetpub\wwwroot\finance\FINANCE\TransactionPost ing.aspx(138,52): error CS0118: 'System.Web.UI.WebControls.DataGridItem.DataItem' denotes a 'property' where a 'method' was expected c:\inetpub\wwwroot\finance\FINANCE\TransactionPost ing.aspx(138,38): error CS0103: The name 'IIF' does not exist in the class or namespace 'ASP.TransactionPosting_aspx'
What might be the problem? Regards
thomson
Ken Cox [Microsoft MVP] wrote: Hi Thomson,
You can use an IIF() function to test the incoming value of Posted_flag and then let it check or uncheck the box. Here's some code:
<asp:templatecolumn HeaderText="Y/N"> <itemtemplate> <asp:checkbox id="Checkbox2" runat="server" Checked='<%# IIF(Container.DataItem("Posted_flag")="Y","true"," false") %>' > </asp:checkbox> </itemtemplate> </asp:templatecolumn>
Let us know if this helps?
Ken Microsoft MVP [ASP.NET]
"thomson" <sa**********@yahoo.com> wrote in message news:11**********************@c13g2000cwb.googlegr oups.com... > Hi all, > Iam binding a datatable with the data grid, In the data table > there is a column as Posted_flag char(1), which can have value either N > or Y . > My issue is that in my grid there is a an > item template with a checkbox control, depending upon the value, Y or N > it should show checked or unchecked. > What should i do for this ? > > Thanks in Advance > > Thomson >
You can use the conditional operator
or conditional ternary operator:
bool booleanStatement = true;
string resultValue = booleanStatement ? "The true part" : "The false part;
// set to "The true part"
Juan T. Llibre
ASP.NET MVP
===========
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:uv**************@TK2MSFTNGP11.phx.gbl... Oh. You didn't say you were using C#. IIF is a VB thing. Need to find the comparable C# syntax.
"thomson" <sa**********@yahoo.com> wrote in message news:11**********************@z14g2000cwz.googlegr oups.com... Hi KEn
Line 136: <HEADERSTYLE VerticalAlign="Top" HorizontalAlign="Center" Wrap="False"></HEADERSTYLE> Line 137: <ITEMTEMPLATE> Line 138: <asp:CheckBox ID="chkPosted" Runat="server" checked='<%# IIF(Container.DataItem("Posted_Flag")=="Y","true", "false") %>' ></asp:CheckBox> Line 139: </ITEMTEMPLATE> Line 140: <EDITITEMTEMPLATE>
Source File: c:\inetpub\wwwroot\finance\FINANCE\TransactionPost ing.aspx Line: 138 Show Detailed Compiler Output:
CMicrosoft (R) Visual C# .NET Compiler version 7.10.6001.4 for Microsoft (R) .NET Framework version 1.1.4322 Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
c:\inetpub\wwwroot\finance\FINANCE\TransactionPost ing.aspx(138,52): error CS0118: 'System.Web.UI.WebControls.DataGridItem.DataItem' denotes a 'property' where a 'method' was expected c:\inetpub\wwwroot\finance\FINANCE\TransactionPost ing.aspx(138,38): error CS0103: The name 'IIF' does not exist in the class or namespace 'ASP.TransactionPosting_aspx'
What might be the problem? Regards
thomson
Ken Cox [Microsoft MVP] wrote: Hi Thomson,
You can use an IIF() function to test the incoming value of Posted_flag and then let it check or uncheck the box. Here's some code:
<asp:templatecolumn HeaderText="Y/N"> <itemtemplate> <asp:checkbox id="Checkbox2" runat="server" Checked='<%# IIF(Container.DataItem("Posted_flag")="Y","true"," false") %>' > </asp:checkbox> </itemtemplate> </asp:templatecolumn>
Let us know if this helps?
Ken Microsoft MVP [ASP.NET]
"thomson" <sa**********@yahoo.com> wrote in message news:11**********************@c13g2000cwb.googlegr oups.com... > Hi all, > Iam binding a datatable with the data grid, In the data table > there is a column as Posted_flag char(1), which can have value either N > or Y . > My issue is that in my grid there is a an > item template with a checkbox control, depending upon the value, Y or N > it should show checked or unchecked. > What should i do for this ? > > Thanks in Advance > > Thomson > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Shivang |
last post by:
Hello Everybody,
I am using Datagrid in VB.net. I don't want the auto
generation of rows in the datagrid (last row shouldnt be
the new row with empty values)..in addition to this the
datagrid...
|
by: Tom Hughes |
last post by:
I want to change one field of all selected rows to a provided value.
Problem 1
I am using the Binding Manager Base to bind the datagrid to the
appropriate dataTable as recommended by KB817247....
|
by: Jeff |
last post by:
IDE: VS 2003 :NET
OS: XP Pro
My app have a form with a tab-control on it. The tab-control have 2
tabpages. One of the tabpages displays a datagrid, and the other tabpage
displays details (order...
|
by: Steve B. |
last post by:
I have a DataGrid on the left and TextBoxes (TB) on the right. The TB's
reflect the contents of the grid cells.
Sorting of columns (both thru VS and programmatically) work fine except,
when the...
|
by: Dave |
last post by:
Tried posting in the Winform Forum without much luck, so posting here...
After inserting a new data row to a DataTable that is bound to a
datagrid, I am unable to change data in a row that is...
|
by: Alpha |
last post by:
I have several textboxes that I need to chang the text when the selection row
is changed in a datagrid. I have the following code. This textbox displayes
the initial selection but when I click on...
|
by: vinayak |
last post by:
Hi
I am displaying data in Datagrid in ASP.NET with
Edit/Update functionality for each row. On the same page I
have 2 Button controls which submits the request to
server. These button controls...
|
by: Brad Shook |
last post by:
I am trying to bind one column of a datagrid to a seperate textbox and
the rest of the fields to a datagrid. the comments are too large to
fit in a datagrid so I created a textbox below the...
|
by: A_PK |
last post by:
I have problem databinding the DataGrid with DataView/DataSet after the
filter...
I create the following proceudre in order for user to filter as many as they
want, but the following code is only...
|
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= |
last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor
information and the details loads the documents for that vendor in a
datagrid. Everything is working fine until I click...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |