Help Pls.Data grid itemtemplate

Discussion in 'ASP .Net Datagrid Control' started by Raghu Raman, May 11, 2005.

  1. Raghu Raman

    Raghu Raman Guest

    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 ***
     
    Raghu Raman, May 11, 2005
    #1
    1. Advertising

  2. Raghu Raman

    Elton W Guest

    Try

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

    HTH

    Elton Wang



    >-----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.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

    ***
    >.
    >
     
    Elton W, May 12, 2005
    #2
    1. Advertising

  3. Raghu Raman

    Raghu Raman Guest

    Hi,Elton

    Thx .But it tells the error,

    'Specified cast not valid'.

    Regards
    Raghu

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Raghu Raman, May 12, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. msnews.microsoft.com
    Replies:
    1
    Views:
    1,442
    Ken Cox [Microsoft MVP]
    Aug 11, 2004
  2. Bennett Haselton
    Replies:
    1
    Views:
    5,340
    Joe Fallon
    Sep 24, 2004
  3. msnews.microsoft.com

    Getting the value of another cell in Grid in ItemTemplate

    msnews.microsoft.com, Aug 9, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    150
    Ken Cox [Microsoft MVP]
    Aug 11, 2004
  4. Raghu Raman

    Data grid help pls

    Raghu Raman, Dec 3, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    92
    Michelle Hlaing
    Dec 30, 2004
  5. Raghu Raman

    Probs in: Data grid calculated column Itemtemplate

    Raghu Raman, May 12, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    282
    Ken Cox [Microsoft MVP]
    May 14, 2005
Loading...

Share This Page