Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6675041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:48:17+00:00 2026-05-26T03:48:17+00:00

I can’t seem to get my details view to enter edit mode. I am

  • 0

I can’t seem to get my details view to enter edit mode. I am programatically binding the data source. When the item command is “edit” I change the mode to “edit” and rebind the datasource. I checked after the control databound and it’s still in edit mode, but the details view is not displaying in edit mode. Any help would be greatly appreciated. Currently my details view is simplified to one element for testing. (this is a cross post from ASP.NET forums, since I could use some help relatively soon)

ASPX:

<div style="width:990px;height:430px;">
    <div style="width:650px;height:430px;float:left;">
    <telerik:RadAjaxLoadingPanel ID="devicesLoadingPanel" runat="server" Skin="Simple" />
    <telerik:RadGrid ID="devicesRadGrid" runat="server" Skin="Simple" AllowPaging="true" Width="550" PageSize="15"
    AutoGenerateColumns="false"  DataSourceID="SqlDataSource1" OnSelectedIndexChanged="devicesGrid_SelectedIndexChanged">
        <MasterTableView DataKeyNames="ID" CommandItemDisplay="Top">
            <Columns>
                <telerik:GridTemplateColumn HeaderText="Type" SortExpression="Type">
                    <ItemTemplate>
                        <asp:Label ID="lblType" runat="server" Text='<%# evalLabelType((Eval("UnitType"))) %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn HeaderText="Name" DataField="Name" SortExpression="Name"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="Description" DataField="Description" SortExpression="Description"></telerik:GridBoundColumn>
                <telerik:GridTemplateColumn HeaderText="Location">
                    <ItemTemplate>
                        <asp:Label ID="lblDevicesLocation" runat="server" Text='<%# evalDevicesLocation(Eval("LocationID")) %>' />  
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        <CommandItemSettings ShowAddNewRecordButton="true" ShowRefreshButton="false"  />
        </MasterTableView>
        <ClientSettings EnablePostBackOnRowClick="true">
            <Selecting AllowRowSelect="true" />
        </ClientSettings>
    </telerik:RadGrid>

    </div>
    <div style="border: 1px solid #000;width:250px;height:430px;float:left;" >
        <asp:DetailsView ID="devicesDetailsView" runat="server" AutoGenerateRows="false" Width="200" Height="430" 
         CellPadding="0" GridLines="None" 
         OnItemCommand="devicesDetails_ItemCommand" OnDataBound="devicesDetails_DataBound">
            <Fields>
                <asp:TemplateField>
                    <ItemTemplate>
                        <span class="titles">Type:</span>
                        <asp:Label ID="lblType" runat="server" Text='<%# evalLabelType((Eval("UnitType"))) %>' />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <span class="titles">Type:</span>
                        <asp:TextBox ID="txtType" runat="server" Text="test" />
                    </EditItemTemplate>
                </asp:TemplateField>

                <asp:CommandField ShowEditButton="true" ButtonType="Button" />
            </Fields>
        </asp:DetailsView>
    </div>

C#:

    protected void devicesGrid_SelectedIndexChanged(object sender, EventArgs e)
    {
        devicesDataKey = devicesRadGrid.SelectedItems[0].OwnerTableView.DataKeyValues[devicesRadGrid.SelectedItems[0].ItemIndex]["ID"].ToString();
        devicesDetailsView.DataSource = getDS(); 
        devicesDetailsView.DataBind();
    }

    protected void devicesDetails_ItemCommand(object sender, DetailsViewCommandEventArgs e)
    {
        if (e.CommandName == "Edit")
        {
            // Switch mode and rebind
            devicesDetailsView.ChangeMode(DetailsViewMode.Edit);
            devicesDetailsView.DataSource = getDS();
            devicesDetailsView.DataBind(); 
        }
    }



    protected void devicesDetails_DataBound(object sender, EventArgs e)
    {

        //HideShowFields(devicesDataKey);  

        // Checking the mode again
        string test22 = devicesDetailsView.CurrentMode.ToString();
    }



    protected DataTable getDS()
    {

        string ID = devicesDataKey;

        // Get that device type!
        SqlCommand getDeviceType = new SqlCommand("SELECT UnitType FROM dbo.unit WHERE ID='" + ID + "'", connection);

        connection.Open();
        devicesTypeID = getDeviceType.ExecuteScalar().ToString();
        connection.Close();
        getDeviceType.Dispose(); 

        // This for attenuation. Depending on the device type it may pull from a different table.
        if (devicesTypeID == "2" || devicesTypeID == "3" || devicesTypeID == "4")
        {
            SqlCommand cmd = new SqlCommand("SELECT UnitType,Unit.Active,Name, Description, PrinterName, PrinterPort, PrinterIP, Unit.IPAddress, Unit.ID, LockHoldTimeout,LightOnTimeout, DoorAlertTimeout, EnableEmergAccess, EnableBizHours, ReaderAttenuation, Attenuation, Unit.LocationID, ScanTime FROM dbo.Unit INNER JOIN dbo.Readers on Unit.ID = Readers.UnitID WHERE Unit.ID='" + ID + "'", connection);
            DataTable dt = new DataTable();
            connection.Open();
            using (cmd)
            {
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
            }
            connection.Close();
            // Attach the data to the details view
            return dt;
        }
        if (devicesTypeID == "5" || devicesTypeID == "6")
        {
            SqlCommand cmd = new SqlCommand("SELECT UnitType,Unit.Active,Name, Description, PrinterName, PrinterPort, PrinterIP, Unit.IPAddress, Unit.ID, LockHoldTimeout,LightOnTimeout, DoorAlertTimeout, EnableEmergAccess, EnableBizHours, ReaderAttenuation, Unit.LocationID, ScanTime, Attenuation FROM dbo.Unit, dbo.Readers WHERE Unit.ID='" + ID + "'", connection);
            DataTable dt = new DataTable();
            connection.Open();
            using (cmd)
            {
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
            }
            connection.Close();
            // Attach the data to the details view
            return dt;
        }

        return null; 
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:48:17+00:00Added an answer on May 26, 2026 at 3:48 am

    I figured it out, it turns out my Telerik Ajax Manager was hiding the error I was getting. I was getting “The DetailsView fired event ModeChanging”, which I resolved using the instructions in the following link: forums.asp.net

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can i get the source code for a WAMP stack installer somewhere? Any help
Can find why i get this error can someone help? package Android.data; public class
Can't seem to get this to work. The idea is to calculate the percentage
Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can any one tell, how to get the result of LINQ query contains group
Can we change the default action of the edit selected row button? Here is
Can I run this in a Windows command prompt like I can run it
Can't seem to figure out what's wrong with the simple getJSON call below. It's
Can someone help me with a command line instruction to drop a single MAMP
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.