Skip to main content
Tab

ASPxDataViewBase.ClientInstanceName Property

Gets or sets the control’s client programmatic identifier.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.2.dll

Declaration

[DefaultValue("")]
public string ClientInstanceName { get; set; }

Property Value

Type Default Description
String String.Empty

A string value that specifies the control’s client identifier.

Remarks

Use the ClientInstanceName property to specify a unique client-side identifier for a control derived from the ASPxDataViewBase. The ClientInstanceName property’s value can be used on the client side to programmatically access the client object rendered for the control in client-side script. This property is particularly important in referencing the data view control when it is contained within a naming container (for example, within an ASPxPageControl‘s page or an ASPxPopupControl‘s window).

If the ClientInstanceName property is not specified for a control, the control’s client identifier is generated automatically, and equals the value of the control’s ID property. Note that in this case, client-side programmatic access to the control is not allowed when the control is contained within a naming container.

Special Characters in Client Instance Name

If the ClientInstanceName property contains special characters, for instance, the dot (.), you cannot access a client object by this name. Call the GetByName(name) method to retrieve the client-side object instead.

<dx:ASPxTextBox ... ClientInstanceName="SomeType.SomeProp" />
var txt = ASPxClientControl.GetControlCollection().GetByName("SomeType.SomeProp");  
txt.SetText("Some Text");  

Example

This example demonstrates how data displayed by the ASPxDataView control can be filtered on custom callbacks initiated by a call to the client PerfromCallback method.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v8.3, Version=8.3.2.0, Culture=neutral, 
PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxDataView" TagPrefix="dxdv" %>  
<%@ Register Assembly="DevExpress.Web.v8.3" Namespace="DevExpress.Web.ASPxEditors"
    TagPrefix="dxe" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<script runat="server">
     protected void Page_Load(object sender, EventArgs e) {
         if(!IsPostBack) { // start value
             cbCountry.DataBind();
             cbCountry.Value = 254; // USA for example
         }
         PrepareFilter();
     }

     protected void PrepareFilter() {
         dvAccessDataSource.SelectParameters[0].DefaultValue = cbCountry.Value.ToString();
         dvCity.DataBind();
     }
</script>


<html xmlns="http://www.w3.org/1999/xhtml" >
 <head runat="server">
     <title>Filtering data within the ASPxDataView using custom callbacks</title>
 </head>
 <body>
     <form id="form1" runat="server">
         <table cellpadding="0" cellspacing="0">
 ComboBox 
            <tr>
                <td align="right" style="white-space: nowrap;">
                    <table cellpadding="0" cellspacing="0"><tr>
                        <td valign="middle">
                            <dxe:ASPxLabel ID="lblFilter" runat="server" 
                              Text="Filter: " AssociatedControlID="cbCountry">
                            </dxe:ASPxLabel>
                        </td>
                        <td valign="middle">
                            <dxe:ASPxComboBox ID="cbCountry" runat="server" 
                              DataSourceID="cbAccessDataSource"
                                TextField="Country" ValueField="CountryId" 
                                 ValueType="System.Int32" EnableIncrementalFiltering="True">
                            <ClientSideEvents SelectedIndexChanged="function(s, e) {
    dvCity.PerformCallback();
}" />
                            </dxe:ASPxComboBox>
                        </td>
                    </tr></table>
                </td>
            </tr>
            <tr><td style="height: 5px;"></td></tr> DataView 
            <tr>
                <td>
                    <dxdv:ASPxDataView ID="dvCity" runat="server" 
                      DataSourceID="dvAccessDataSource" 
                      ClientInstanceName="dvCity" Width="580px" AllowPaging="False">
                        <ItemStyle Height="60px" Width="150px" />
                        <ItemTemplate>
                            <table cellpadding="0" cellspacing="0">
                                <tr>
                                    <th>CountryId:</th>
                                    <td rowspan="3"><div style="width: 5px;"></div></td>
                                    <td><asp:Label ID="CountryIdLabel" runat="server" 
                                           Text='<%# Eval("CountryId") %>'>
                                           </asp:Label></td>
                                </tr>
                                <tr>
                                    <th>CityId:</th>
                                    <td><asp:Label ID="CityIdLabel" runat="server" 
                                           Text='<%# Eval("CityId") %>'></asp:Label></td>
                                </tr>
                                <tr>
                                    <th>City:</th>
                                    <td><asp:Label ID="CityLabel" runat="server" 
                                            Text='<%# Eval("City") %>'>
                                            </asp:Label></td>
                                </tr>
                            </table>
                        </ItemTemplate>
                        <Border BorderColor="#A0A0A0" BorderStyle="Solid" BorderWidth="1px" />
                        <Paddings Padding="5px" />
                    </dxdv:ASPxDataView>
                </td>
            </tr>         </table>

        <asp:AccessDataSource ID="cbAccessDataSource" runat="server" 
            DataFile="~/App_Data/EditorsSampleDB.mdb"
            SelectCommand="SELECT * FROM [Countries]">
        </asp:AccessDataSource>
        <asp:AccessDataSource ID="dvAccessDataSource" runat="server" 
            DataFile="~/App_Data/EditorsSampleDB.mdb"
            SelectCommand="SELECT * FROM [Cities] WHERE ([CountryId] = ?)">
            <SelectParameters>
                <asp:Parameter DefaultValue="1" Name="CountryId" Type="Int32" />
            </SelectParameters>
        </asp:AccessDataSource>     </form>
 </body>
 </html>
See Also