新手一问,
我在formview1的edittemplate 中加入了一个label.
想在ads.select时用findcontrol设定文字, 但不成功.. 请问是否ADS2出了问题?
谢谢
protected void FormView1_DataBound(object sender, EventArgs e)
{
Label cctb0 = (Label)FormView1.FindControl("cctb");
cctb0.Text = "found";
^^^^^^^^^^^^^^^^^^^^^^ 无法compile
}
===ADS2 code
<asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/db1.mdb"
InsertCommand="INSERT INTO [form1] ( [row1], [row2], [row3]) VALUES (?, ?, ?)"
SelectCommand="SELECT * FROM [form1] where id=@id" UpdateCommand="UPDATE [form1] SET [row1] = ?, [row2] = ?, [row3] = ? WHERE [id] = ?">
<UpdateParameters>
<asp:Parameter Name="row1" Type="String" />
<asp:Parameter Name="row2" Type="String" />
<asp:Parameter Name="row3" Type="DateTime" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="row1" Type="String" />
<asp:Parameter Name="row2" Type="String" />
<asp:Parameter Name="row3" Type="DateTime" />
</InsertParameters>
<SelectParameters>
<asp:Parameter Name="@id" />
</SelectParameters>
</asp:AccessDataSource>
<asp:FormView ID="FormView1" runat="server" DataKeyNames="id" DataSourceID="AccessDataSource2"
DefaultMode="Edit" OnItemInserted="FormView1_ItemInserted" OnDataBound="FormView1_DataBound">
<EditItemTemplate>
<asp:Label ID="cctb" runat="server"></asp:Label><br />
<br />
id:
<asp:Label ID="idLabel1" runat="server" Text='<%# Eval("id") %>'></asp:Label><br />
row1:
<asp:TextBox ID="row1TextBox" runat="server" Text='<%# Bind("row1") %>'>
</asp:TextBox><br />
row2:
<asp:TextBox ID="row2TextBox" runat="server" Text='<%# Bind("row2") %>'>
</asp:TextBox><br />
row3:
<asp:TextBox ID="row3TextBox" runat="server" Text='<%# Bind("row3") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
</asp:FormView>