using binding tag in Userconrol....

S

somequestion

< uc1:BoardWrite ID="BoardWrite1" CommentId="<%# Eval("CommentId") %>"
runat="server" />

this is visual studio 2005 asp.net tag.
first it's nor working..but i need this
because i will use this usercontrol lots of place in just 1page.
so i have to give commentId to BoardWirte control
how can i solve this?
Bind() method also doesn't work.
thankx.
 
J

Joshua Mitts

I'm not clear on what you want to accomplish with the Eval() command? Can
you describe exactly what you want to do?

If you want to bind data, you need to use DataBinder.Eval("<data column goes
here>"), and then use DataBind() on your control or page.
 
S

somequestion

<DataList >
<ItemTemplate>

<uc1:BoardCommentWrite ID="BoardCommentWrite1" CommentId="<%#
Eval("CommentId") %>" runat="server" />

</ItemTemplate>
</DataList >

my CODE is like this. datalist make a lof of BoardCommentWrite usercontrol
that' why i have to distinguish between controls but it's nor working
complier say

Error 1 The server tag is not well formed.
C:\Project2005\WebSite\Minoworks\Board\BoardComment.ascx 72

thanks
 
J

Joshua Mitts

Oh I'm sorry, your problem there is the quoting. You need your CommendId= to
use single quotes, as follows:

<uc1:BoardCommentWrite ID="BoardCommentWrite1" CommentId='<%#
Eval("CommentId") %>' runat="server" />
 
S

somequestion

there's no error message now but it still doesn't work.
i used Bind Method but it also not work
wow....it driving me crazy...
help..me..

Yesterday....i've posted another.question...is like below

==============================================================
in asp.net 2.0
i want to get [ CommentId ] value from database.
BoardCommentWrite have a CommentId property as public
so when i attach BoardCommentWrite usercontrol i want to get CommentId value
from DataList so i write my code like below..

<DataList >
<ItemTemplate>

<uc1:BoardCommentWrite ID="BoardCommentWrite1"
CommentId='<%# Bind("CommentId") %>' runat="server" />

</ItemTemplate>
</DataList >

that' why i have to distinguish between controls but it's not working

it give me " null value "

is there any way to solve this problem?

thanks
 
J

Joshua Mitts

You want to use DataBinder.Eval() in the control, and MyDataList.DataBind()
in your code, i.e.

<uc1:BoardCommentWrite ID="BoardCommentWrite1"
CommentId='<%# DataBinder.Eval(Container.DataItem, "CommentId")
%>' runat="server" />

Then in your code, call .DataBind() on your DataList control.

--

Joshua Mitts
(e-mail address removed)

somequestion said:
there's no error message now but it still doesn't work.
i used Bind Method but it also not work
wow....it driving me crazy...
help..me..

Yesterday....i've posted another.question...is like below

==============================================================
in asp.net 2.0
i want to get [ CommentId ] value from database.
BoardCommentWrite have a CommentId property as public
so when i attach BoardCommentWrite usercontrol i want to get CommentId
value
from DataList so i write my code like below..

<DataList >
<ItemTemplate>

<uc1:BoardCommentWrite ID="BoardCommentWrite1"
CommentId='<%# Bind("CommentId") %>' runat="server" />

</ItemTemplate>
</DataList >

that' why i have to distinguish between controls but it's not working

it give me " null value "

is there any way to solve this problem?

thanks







Joshua Mitts said:
Oh I'm sorry, your problem there is the quoting. You need your CommendId=
to use single quotes, as follows:

<uc1:BoardCommentWrite ID="BoardCommentWrite1" CommentId='<%#
Eval("CommentId") %>' runat="server" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top