I have dataRepeater.
How can I do:
<ItemTemplate>
<asp:TableCell >
<%If viewState("type") = "3" then%>
<%# writeLine(DataBinder.Eval(Container.DataItem,
"name")%>
<%else%>
<%# writeLine1(DataBinder.Eval(Container.DataItem,
"name1")%>
<%end if%>
</asp:TableCell>
</ItemTemplate>
The problem is that when viewState("type") =3 then I have different
dataSource.
If statement doesn't work like I write.
Any idea?
Thanks,S 5 1396
It is possible to do inline formatting, but as the formatting gets more
complex, it's better to do it in codebehind hooking into the ItemDataBound
event.
You can learn more on both methods at: http://openmymind.net/index.aspx?documentId=8#4
basically though, to do it your way, I would do:
<asp:literal runat="server" visible='<%# (ViewState("type") = "3")'
id="x"><%# DataBinder.Eval(Container.DataItem, "name") %></asp:literal>
<asp:literal runat="server" visible='<%# (ViewState("type") <> "3")'
id="x"><%# DataBinder.Eval(Container.DataItem, "name1") %></asp:literal>
As you can see, each literal will be visible based on whether the condition
is true or false.
Again, I would urge you to look into doing this in the ItemDataBound event.
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"SimonZ" <si*********@studio-moderna.com> wrote in message
news:OJ**************@TK2MSFTNGP09.phx.gbl... I have dataRepeater.
How can I do:
<ItemTemplate> <asp:TableCell > <%If viewState("type") = "3" then%> <%# writeLine(DataBinder.Eval(Container.DataItem, "name")%> <%else%> <%# writeLine1(DataBinder.Eval(Container.DataItem, "name1")%> <%end if%> </asp:TableCell> </ItemTemplate>
The problem is that when viewState("type") =3 then I have different dataSource.
If statement doesn't work like I write.
Any idea?
Thanks,S
Thank you Carl.
Do you know when to use databinding control event?
Or you always use item_dataBound event?
regards,
Simon
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2***************@TK2MSFTNGP12.phx.gbl... It is possible to do inline formatting, but as the formatting gets more complex, it's better to do it in codebehind hooking into the ItemDataBound event.
You can learn more on both methods at: http://openmymind.net/index.aspx?documentId=8#4
basically though, to do it your way, I would do:
<asp:literal runat="server" visible='<%# (ViewState("type") = "3")' id="x"><%# DataBinder.Eval(Container.DataItem, "name") %></asp:literal> <asp:literal runat="server" visible='<%# (ViewState("type") <> "3")' id="x"><%# DataBinder.Eval(Container.DataItem, "name1") %></asp:literal>
As you can see, each literal will be visible based on whether the condition is true or false.
Again, I would urge you to look into doing this in the ItemDataBound event.
Karl -- MY ASP.Net tutorials http://www.openmymind.net/
"SimonZ" <si*********@studio-moderna.com> wrote in message news:OJ**************@TK2MSFTNGP09.phx.gbl...I have dataRepeater.
How can I do:
<ItemTemplate> <asp:TableCell > <%If viewState("type") = "3" then%> <%# writeLine(DataBinder.Eval(Container.DataItem, "name")%> <%else%> <%# writeLine1(DataBinder.Eval(Container.DataItem, "name1")%> <%end if%> </asp:TableCell> </ItemTemplate>
The problem is that when viewState("type") =3 then I have different dataSource.
If statement doesn't work like I write.
Any idea?
Thanks,S
Hi Karl,
I choose ItemDataBound event
In your example you declare dataItem as new owner:
Owner owner = (Owner)e.Item.DataItem;
In my example, how can I read the value of the first column, for example:
string column1;
column1=e.Item.DataItem(1);
or something similar?
regards,S
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2***************@TK2MSFTNGP12.phx.gbl... It is possible to do inline formatting, but as the formatting gets more complex, it's better to do it in codebehind hooking into the ItemDataBound event.
You can learn more on both methods at: http://openmymind.net/index.aspx?documentId=8#4
basically though, to do it your way, I would do:
<asp:literal runat="server" visible='<%# (ViewState("type") = "3")' id="x"><%# DataBinder.Eval(Container.DataItem, "name") %></asp:literal> <asp:literal runat="server" visible='<%# (ViewState("type") <> "3")' id="x"><%# DataBinder.Eval(Container.DataItem, "name1") %></asp:literal>
As you can see, each literal will be visible based on whether the condition is true or false.
Again, I would urge you to look into doing this in the ItemDataBound event.
Karl -- MY ASP.Net tutorials http://www.openmymind.net/
"SimonZ" <si*********@studio-moderna.com> wrote in message news:OJ**************@TK2MSFTNGP09.phx.gbl...I have dataRepeater.
How can I do:
<ItemTemplate> <asp:TableCell > <%If viewState("type") = "3" then%> <%# writeLine(DataBinder.Eval(Container.DataItem, "name")%> <%else%> <%# writeLine1(DataBinder.Eval(Container.DataItem, "name1")%> <%end if%> </asp:TableCell> </ItemTemplate>
The problem is that when viewState("type") =3 then I have different dataSource.
If statement doesn't work like I write.
Any idea?
Thanks,S
Well, you can use DataBinder.Eval() in your code behind like you would in
your aspx, such as DataBinder.Eval(e.Item.DataItem, "Blah")
or, you can cast DataItem to the specific type. If you are binding from a
dataset, datatabele or dataview, you would do:
DataRowView dv = ctype(e.Item.DataItem, DataRowView)
dv("Column1")
dv(0)
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"SimonZ" <si*********@studio-moderna.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Hi Karl,
I choose ItemDataBound event
In your example you declare dataItem as new owner: Owner owner = (Owner)e.Item.DataItem;
In my example, how can I read the value of the first column, for example:
string column1;
column1=e.Item.DataItem(1);
or something similar?
regards,S
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:%2***************@TK2MSFTNGP12.phx.gbl... It is possible to do inline formatting, but as the formatting gets more complex, it's better to do it in codebehind hooking into the ItemDataBound event.
You can learn more on both methods at: http://openmymind.net/index.aspx?documentId=8#4
basically though, to do it your way, I would do:
<asp:literal runat="server" visible='<%# (ViewState("type") = "3")' id="x"><%# DataBinder.Eval(Container.DataItem, "name") %></asp:literal> <asp:literal runat="server" visible='<%# (ViewState("type") <> "3")' id="x"><%# DataBinder.Eval(Container.DataItem, "name1") %></asp:literal>
As you can see, each literal will be visible based on whether the condition is true or false.
Again, I would urge you to look into doing this in the ItemDataBound event.
Karl -- MY ASP.Net tutorials http://www.openmymind.net/
"SimonZ" <si*********@studio-moderna.com> wrote in message news:OJ**************@TK2MSFTNGP09.phx.gbl...I have dataRepeater.
How can I do:
<ItemTemplate> <asp:TableCell > <%If viewState("type") = "3" then%> <%# writeLine(DataBinder.Eval(Container.DataItem, "name")%> <%else%> <%# writeLine1(DataBinder.Eval(Container.DataItem, "name1")%> <%end if%> </asp:TableCell> </ItemTemplate>
The problem is that when viewState("type") =3 then I have different dataSource.
If statement doesn't work like I write.
Any idea?
Thanks,S
thank you Karl,
a little step for you but great work for me :)
regards,S
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2***************@TK2MSFTNGP11.phx.gbl... Well, you can use DataBinder.Eval() in your code behind like you would in your aspx, such as DataBinder.Eval(e.Item.DataItem, "Blah")
or, you can cast DataItem to the specific type. If you are binding from a dataset, datatabele or dataview, you would do:
DataRowView dv = ctype(e.Item.DataItem, DataRowView)
dv("Column1") dv(0)
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"SimonZ" <si*********@studio-moderna.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... Hi Karl,
I choose ItemDataBound event
In your example you declare dataItem as new owner: Owner owner = (Owner)e.Item.DataItem;
In my example, how can I read the value of the first column, for example:
string column1;
column1=e.Item.DataItem(1);
or something similar?
regards,S
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:%2***************@TK2MSFTNGP12.phx.gbl... It is possible to do inline formatting, but as the formatting gets more complex, it's better to do it in codebehind hooking into the ItemDataBound event.
You can learn more on both methods at: http://openmymind.net/index.aspx?documentId=8#4
basically though, to do it your way, I would do:
<asp:literal runat="server" visible='<%# (ViewState("type") = "3")' id="x"><%# DataBinder.Eval(Container.DataItem, "name") %></asp:literal> <asp:literal runat="server" visible='<%# (ViewState("type") <> "3")' id="x"><%# DataBinder.Eval(Container.DataItem, "name1") %></asp:literal>
As you can see, each literal will be visible based on whether the condition is true or false.
Again, I would urge you to look into doing this in the ItemDataBound event.
Karl -- MY ASP.Net tutorials http://www.openmymind.net/
"SimonZ" <si*********@studio-moderna.com> wrote in message news:OJ**************@TK2MSFTNGP09.phx.gbl... I have dataRepeater.
How can I do:
<ItemTemplate> <asp:TableCell > <%If viewState("type") = "3" then%> <%# writeLine(DataBinder.Eval(Container.DataItem, "name")%> <%else%> <%# writeLine1(DataBinder.Eval(Container.DataItem, "name1")%> <%end if%> </asp:TableCell> </ItemTemplate>
The problem is that when viewState("type") =3 then I have different dataSource.
If statement doesn't work like I write.
Any idea?
Thanks,S
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Fábio Mendes |
last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with
things or the python-list sent my msg to /dev/null. I couldn't find
anything related in previous PEP's, so here it goes a...
|
by: Nerox |
last post by:
Hi, If i write:
#include <stdio.h>
int foo(int);
int main(void){
int a = 3;
foo(a);
}
|
by: eman1000 |
last post by:
I was recently looking at the prototype library
(http://prototype.conio.net/) and I noticed the author used the
following syntax:
Object.extend(MyObj.prototype, {
my_meth1: function(){},...
|
by: Steven Bethard |
last post by:
The PEP below should be mostly self explanatory. I'll try to keep the
most updated versions available at:
http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
|
by: Steven Bethard |
last post by:
I've updated the PEP based on a number of comments on comp.lang.python.
The most updated versions are still at:
http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
|
by: Steven Bethard |
last post by:
Ok, I finally have a PEP number. Here's the most updated version of the
"make" statement PEP. I'll be posting it shortly to python-dev.
Thanks again for the previous discussion and suggestions!...
|
by: Steven Bethard |
last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The
patch is available at:
http://bugs.python.org/1472459
and I've pasted the full text below.
I've tried to be more explicit about...
|
by: Steve |
last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement
I got ASP error number 13 when I use the SELECT...FOR UPDATE statement
as below.
However, if I use SELECT statement without...
|
by: dspfun |
last post by:
Hi!
The words "expression" and "statement" are often used in C99 and C-
textbooks, however, I am not sure of the clear defintion of these
words with respect to C.
Can somebody provide a sharp...
|
by: florian.loitsch |
last post by:
According to the spec Section 14 the production
SourceElements:SourceElements SourceElement is evaluated as follows:
1. Evaluate SourceElements.
2. If Result(1) is an abrupt completion, return...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
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: 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: 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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |