[英]Webcontrol as a property of another webcontrol
In asp.net sometimes a webcontrol needs to reference another webcontrol such as the gridview needs the id of the datasource object that it will bind to. 在asp.net中,有时一个Web控件需要引用另一个Web控件,例如gridview需要它将绑定到的数据源对象的ID。
I have a property of my webcontrol that is a string (the id of the webcontrol I want to reference). 我的webcontrol的属性是一个字符串(我要引用的webcontrol的ID)。 How do I access the actual webcontrol based on this id? 如何根据此ID访问实际的WebControl?
Here's a sample of a GridView bound to an ObjectDataSource, with the ObjectDataSource binding to a DropDownList for a parameter. 这是绑定到ObjectDataSource的GridView的示例,而ObjectDataSource绑定到参数的DropDownList。 This should get you started. 这应该使您入门。
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
DataSourceID="CustomerObjectDataSource"
DataKeyNames="CustomerID"
AllowPaging="True"
AllowSorting="True" AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True" AutoGenerateSelectButton="True"
onrowdeleted="GridView1_RowDeleted" onrowupdated="GridView1_RowUpdated">
<Columns>
...
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="CustomerObjectDataSource" runat="server"
EnablePaging="True"
MaximumRowsParameterName="totalRows"
StartRowIndexParameterName="firstRow"
TypeName="Northwind.Business.CustomerSource"
DataObjectTypeName="Northwind.Business.CustomerDTO"
SelectMethod="Load"
UpdateMethod="Save"
InsertMethod="Insert"
DeleteMethod="Delete"
SelectCountMethod="CustomerCount"
SortParameterName="sortExpression">
<SelectParameters>
<asp:ControlParameter ControlID="ddlRegion" Name="region"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:ObjectDataSource>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.