程序代码:
protected void GridView1_ItemDataBound1(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem) //红色代表是编辑中的项目。Grid有很多item ,全部控件都可以在Item中找到
{
GridEditableItem commandItem = e.Item as GridEditableItem;
Label lb = (Label)commandItem.FindControl("Label1");
if (lb != null)
lb.Text = "fsdaf";
}
ASPX:
<MasterTableView AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource1" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" CommandItemDisplay="TopAndBottom">
<CommandItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server">Default Text</asp:LinkButton>
<asp:Label ID="Label2" runat="server" Text="NameLab"></asp:Label>
</CommandItemTemplate>
<FormTemplate>
<asp:Label ID="Label1" runat="server" Text="NameLab"></asp:Label>
</FormTemplate> //edititem中的项目
</MasterTableView>
</radG:RadGrid>
浙公网安备 33010602011771号