Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - show check box in repeater based on database value

 
Thread Tools Search this Thread
Old 08-10-2005, 04:47 PM   #1
Default show check box in repeater based on database value


Hello All,
I display a list of entries with a checkbox against them using a
repeater control bound to a database table. Based on the value of database
table I want to either show the checkbox for a row or not to show, how do I
accomplish that using a repeater control ?
Should I do something like this

<%if (((DataRowView)Container.DataItem)["bThisUserHasIt"] == 0)

{ %><asp:CheckBox ID="chkBookMarkID" text='<%#
((DataRowView)Container.DataItem)["nBookMarkID"] %>' runat="server"
ForeColor="White" Font-Size="1px" /<%} %>


(this one does not work , but I am thinking it might be possible to do it
like that, get this error, Error 2 The name 'Container' does not exist in
the current context
C:\Inetpub\wwwroot\allenandovery\bookmarks\recentb ookmarks.aspx 24 35
C:\...\allenandovery\
)

or is there a better way to do it, checking and specifying the value in code
behind?


Thanks a lot for your support.
Imran.




Imran Aziz
  Reply With Quote
Old 08-10-2005, 06:33 PM   #2
=?Utf-8?B?U3JlZWppdGggUmFt?=
 
Posts: n/a
Default RE: show check box in repeater based on database value
You can move the same code to simple function to determin if the check box
will be visible or not

<asp:CheckBox Visible='<%#VisibleYesNo(DataBinder.Eval(Container .DataItem,
"bThisUserHasIt").ToString())%>' ID="chk" Runat="server"></asp:CheckBox>

Please note the

Visible='<%#VisibleYesNo(DataBinder.Eval (Container.DataItem,
"bThisUserHasIt").ToString())%>'

the VisibleYesNo funtion would look like

protected bool VisibleYesNo (string val)
{
if(val=="0")
return(true);

return(false);
}



"Imran Aziz" wrote:

> Hello All,
> I display a list of entries with a checkbox against them using a
> repeater control bound to a database table. Based on the value of database
> table I want to either show the checkbox for a row or not to show, how do I
> accomplish that using a repeater control ?
> Should I do something like this
>
> <%if (((DataRowView)Container.DataItem)["bThisUserHasIt"] == 0)
>
> { %><asp:CheckBox ID="chkBookMarkID" text='<%#
> ((DataRowView)Container.DataItem)["nBookMarkID"] %>' runat="server"
> ForeColor="White" Font-Size="1px" /<%} %>
>
>
> (this one does not work , but I am thinking it might be possible to do it
> like that, get this error, Error 2 The name 'Container' does not exist in
> the current context
> C:\Inetpub\wwwroot\allenandovery\bookmarks\recentb ookmarks.aspx 24 35
> C:\...\allenandovery\
> )
>
> or is there a better way to do it, checking and specifying the value in code
> behind?
>
>
> Thanks a lot for your support.
> Imran.
>
>
>



=?Utf-8?B?U3JlZWppdGggUmFt?=
  Reply With Quote
Old 08-11-2005, 08:34 AM   #3
Patrick.O.Ige
 
Posts: n/a
Default Re: show check box in repeater based on database value
You could make use of the Finbyvalue method and loop through the checkboxes.
Or create a function VisibleYesorNo function as adviced.
Patrick


"Imran Aziz" <> wrote in message
news:...
> Hello All,
> I display a list of entries with a checkbox against them using a
> repeater control bound to a database table. Based on the value of database
> table I want to either show the checkbox for a row or not to show, how do

I
> accomplish that using a repeater control ?
> Should I do something like this
>
> <%if (((DataRowView)Container.DataItem)["bThisUserHasIt"] == 0)
>
> { %><asp:CheckBox ID="chkBookMarkID" text='<%#
> ((DataRowView)Container.DataItem)["nBookMarkID"] %>' runat="server"
> ForeColor="White" Font-Size="1px" /<%} %>
>
>
> (this one does not work , but I am thinking it might be possible to do it
> like that, get this error, Error 2 The name 'Container' does not exist in
> the current context
> C:\Inetpub\wwwroot\allenandovery\bookmarks\recentb ookmarks.aspx 24 35
> C:\...\allenandovery\
> )
>
> or is there a better way to do it, checking and specifying the value in

code
> behind?
>
>
> Thanks a lot for your support.
> Imran.
>
>





Patrick.O.Ige
  Reply With Quote
Old 08-11-2005, 05:57 PM   #4
Imran Aziz
 
Posts: n/a
Default Re: show check box in repeater based on database value
Wonderful thanks a lot that worked great.
Imran
"Sreejith Ram" <> wrote in message
news:4C492987-EEC2-4BA8-BD25-...
> You can move the same code to simple function to determin if the check box
> will be visible or not
>
> <asp:CheckBox
> Visible='<%#VisibleYesNo(DataBinder.Eval(Container .DataItem,
> "bThisUserHasIt").ToString())%>' ID="chk" Runat="server"></asp:CheckBox>
>
> Please note the
>
> Visible='<%#VisibleYesNo(DataBinder.Eval (Container.DataItem,
> "bThisUserHasIt").ToString())%>'
>
> the VisibleYesNo funtion would look like
>
> protected bool VisibleYesNo (string val)
> {
> if(val=="0")
> return(true);
>
> return(false);
> }
>
>
>
> "Imran Aziz" wrote:
>
>> Hello All,
>> I display a list of entries with a checkbox against them using a
>> repeater control bound to a database table. Based on the value of
>> database
>> table I want to either show the checkbox for a row or not to show, how do
>> I
>> accomplish that using a repeater control ?
>> Should I do something like this
>>
>> <%if (((DataRowView)Container.DataItem)["bThisUserHasIt"] == 0)
>>
>> { %><asp:CheckBox ID="chkBookMarkID" text='<%#
>> ((DataRowView)Container.DataItem)["nBookMarkID"] %>' runat="server"
>> ForeColor="White" Font-Size="1px" /<%} %>
>>
>>
>> (this one does not work , but I am thinking it might be possible to do it
>> like that, get this error, Error 2 The name 'Container' does not exist in
>> the current context
>> C:\Inetpub\wwwroot\allenandovery\bookmarks\recentb ookmarks.aspx 24 35
>> C:\...\allenandovery\
>> )
>>
>> or is there a better way to do it, checking and specifying the value in
>> code
>> behind?
>>
>>
>> Thanks a lot for your support.
>> Imran.
>>
>>
>>





Imran Aziz
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
TRADING FEMALE CELEB INTERVIEWS ON DVD stu DVD Video 1 05-26-2008 09:39 AM
DVD Verdict reviews: THE OPRAH WINFREY SHOW: 20TH ANNIVERSARY DVD COLLECTION and more! DVD Verdict DVD Video 0 12-14-2005 09:14 AM
Classic Original Broadcasts Trading List - Updated ( w/o/c ) porkys1982@sbcglobal.net DVD Video 0 12-05-2005 03:38 AM
Classic Original Broadcasts Trading List - Updated ( w/o/c ) porkys1982@sbcglobal.net DVD Video 0 11-19-2005 04:46 PM
Original Airings : The A-Team , M*A*S*H , Taxi , Barney Miller , WKRP porkys1982@sbcglobal.net DVD Video 0 08-15-2005 03:09 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46