Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Help Pls.Data grid itemtemplate

Reply
Thread Tools

Help Pls.Data grid itemtemplate

 
 
Raghu Raman
Guest
Posts: n/a
 
      05-11-2005

Hi,
am using the datagrid with the item template property.Inside it i have
the check box bounded to my database.I want the check box to be
automatically checked when it is loaded.
so i used the following code,

<Columns>
<asp:BoundColumn DataField="Tid" HeaderText="SI No"></asp:BoundColumn>
<asp:BoundColumn DataField="Tname" HeaderText="Name"></asp:BoundColumn>
<asp:TemplateColumn><ItemTemplate> <asp:CheckBox ID="chk" Runat=server
Checked ='<%#Container.DataItem("bools")%>'/>
</ItemTemplate> </asp:TemplateColumn>
</Columns>

-----------------------------id i run my app,
It tells the following error.

Compiler Error Message: CS0118:
'System.Web.UI.WebControls.DataGridItem.DataItem' denotes a 'property'
where a 'method' was expected

Source Error:



Line 23: using System.Web.UI.WebControls;
Line 24: using System.Web.UI.HtmlControls;
Line 25: using ASP;
Line 26:
Line 27:
----------------------------
Table structure:
~~~~~~~~~~~~~~~~~~~~~`
Tid Tname bools (nvarchar(5))
----------- -------------------- -----
1 one TRUE
2 two TRUE
6 six TRUE
Could u pls tell where i went wrong.

Thx & Regards
Raghu

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Elton W
Guest
Posts: n/a
 
      05-12-2005
Try

<asp:CheckBox ID="chk" Runat=server Checked ='<%#
DataBinder.Eval(Container.DataItem, "bools")%>'/>

HTH

Elton Wang
http://www.velocityreviews.com/forums/(E-Mail Removed)


>-----Original Message-----
>
>Hi,
> am using the datagrid with the item template

property.Inside it i have
>the check box bounded to my database.I want the check box

to be
>automatically checked when it is loaded.
>so i used the following code,
>
><Columns>
><asp:BoundColumn DataField="Tid" HeaderText="SI

No"></asp:BoundColumn>
><asp:BoundColumn DataField="Tname"

HeaderText="Name"></asp:BoundColumn>
><asp:TemplateColumn><ItemTemplate>

<asp:CheckBox ID="chk" Runat=server
>Checked ='<%#Container.DataItem("bools")%>'/>
></ItemTemplate> </asp:TemplateColumn>
></Columns>
>
>-----------------------------id i run my app,
>It tells the following error.
>
>Compiler Error Message: CS0118:
>'System.Web.UI.WebControls.DataGridItem.DataIte m' denotes

a 'property'
>where a 'method' was expected
>
>Source Error:
>
>
>
>Line 23: using System.Web.UI.WebControls;
>Line 24: using System.Web.UI.HtmlControls;
>Line 25: using ASP;
>Line 26:
>Line 27:
> ----------------------------
>Table structure:
>~~~~~~~~~~~~~~~~~~~~~`
>Tid Tname bools (nvarchar(5))
>----------- -------------------- -----
>1 one TRUE
>2 two TRUE
>6 six TRUE
>Could u pls tell where i went wrong.
>
>Thx & Regards
>Raghu
>
>*** Sent via Developersdex http://www.developersdex.com

***
>.
>

 
Reply With Quote
 
 
 
 
Raghu Raman
Guest
Posts: n/a
 
      05-12-2005

Hi,Elton

Thx .But it tells the error,

'Specified cast not valid'.

Regards
Raghu

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Probs in: Data grid calculated column Itemtemplate Raghu Raman ASP .Net Datagrid Control 1 05-14-2005 02:22 AM
can code inside a Repeater's ItemTemplate modify controls in the ItemTemplate? Bennett Haselton ASP .Net 1 09-24-2004 01:59 AM
Getting the value of another cell in Grid in ItemTemplate msnews.microsoft.com ASP .Net 1 08-11-2004 12:42 AM
Getting the value of another cell in Grid in ItemTemplate msnews.microsoft.com ASP .Net Web Controls 1 08-11-2004 12:42 AM
Getting the value of another cell in Grid in ItemTemplate msnews.microsoft.com ASP .Net Datagrid Control 1 08-11-2004 12:42 AM



Advertisments