项目模板无法绑定值 [英] Item template can't bind value

查看:78
本文介绍了项目模板无法绑定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有模板字段的日程表日历.

I have a schedule calender with a template field.

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<contenttemplate>
<rw:schedulecalendar id="Schedule1"  runat="server" StartOfTimeScale="08:00:00"

ShowValueMarks="True" EndOfTimeScale="17:00:00" BorderColor="#D04C87" 

DateField="EventDate" StartTimeField="StartTime" EndTimeField="EndTime" ItemStyleField="Color"

Layout="Vertical" GridLines="Both"  CellSpacing="0" 

DataKeyNames="ID" HorizontalAlign="NotSet" 

StartDay="Monday" EnableEmptySlotClick="True" 

meta:resourcekey="Schedule1Resource1" StartDate="2010-04-05" Weeks="1" 

FullTimeScale="True" CellPadding="0">

<timetemplate>
<%# Convert.ToDateTime(Container.DataItem).ToShortTimeString() %></timetemplate>
<datestyle cssclass="title"></datestyle>

<datetemplate>
<%# Convert.ToDateTime(Container.DataItem).ToString("ddd") ></datetemplate>
<backgroundstyle cssclass="bground"></backgroundstyle>
<itemstyle cssclass="item" height="30px" wrap="True"></itemstyle>
<timestyle cssclass="rangeheader"></timestyle>

<itemtemplate>
<asp:LinkButton id="LinkButton1" runat="Server" CommandName="Select" ><%#Eval("Subject")%></asp:LinkButton>
</itemtemplate>

</contenttemplate>



然后将代码与时间表日历绑定到数据集.



And then I bind the dataset with schedule calendar in code.

Schedule1.DataSource = _Ds;
Schedule1.DataBind();


但是链接按钮无法获取值.请任何人帮助我


but link button don''t get the value.pls any one help me

推荐答案

尝试这种方式

try this way

<asp:HyperLink ID="hyp_Edit" ImageUrl="~/Admin/Images/edit.jpg" NavigateUrl='<%#"~/Admin/CandidateDetails.aspx.?Id="+Eval("CandidateID") %>'

                                               Text='<%#Eval("IsFresher")%>' runat="server"></asp:HyperLink>


您的链接按钮结束标记丢失:

your link button end tag is missed:

<asp:linkbutton id="LinkButton1" runat="Server" commandname="Select" >
<%#Eval("Subject")%>




并且如果您从repeter Item命令或任何其他repeter事件中调用bind方法,则需要回发一个绑定它.




and if you call your bind method from repeter Item command or any other repeter event then one post back needed to bind it.

ScriptManager.RegisterStartupScript(this, this.GetType(), "Postback", "postback();", true);



javascript:



javascript:

postback()
{
  _dopostback(''LinkButton1'','''');
}


您可以将其包装在此层次结构中

You may wrap in this hierarchy

<asp:TemplateField>
    <ItemTemplate>
            <asp:UpdatePanel runat="server">
                <ContentTemplate>
                    <asp:LinkButton id="LinkButton1" runat="Server" CommandName="Select" ><%#Eval("Subject")%></asp:LinkButton>
                </ContentTemplate>
            </asp:UpdatePanel>
      </ItemTemplate>
</asp:TemplateField>



将所有内容放入外部项目模板中.如果该主题存在于您的结果集中,则应该绑定该主题,否则请调试您的数据源



Put everything inside an outer item template. If the subject is present in your result set it supposed to be bound, else debug your data source


这篇关于项目模板无法绑定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆