locked
Detailsview always editing first row of the gridview, On DynamidData custom pages. RRS feed

  • Question

  • User-1759624489 posted

     Hello. When I click the button edit on the gridview

     

    protected void OnGridViewRowEditing(object sender, EventArgs e) {
            //DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
            GridView1.EditIndex = -1;
           
            DetailsView1.ChangeMode(DetailsViewMode.Edit);
        }

     

    The detailsview is set in edit mode, but not on the selected row but on the first row always.

     

    Any idea??

        <asp:LinqDataSource ID="GridDataSource" runat="server" EnableDelete="true" EnableUpdate="true">
               <WhereParameters>
                        <asp:DynamicControlParameter ControlID="FilterRepeater" />
                    </WhereParameters>
                </asp:LinqDataSource>

                <asp:Panel ID="DetailsPanel" runat="server">
                  <br /><br />

                  <asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableDelete="true" EnableInsert="true" EnableUpdate="true">
                      <WhereParameters>
                          <asp:DynamicControlParameter ControlID="GridView1" />
                      </WhereParameters>
                  </asp:LinqDataSource>
                  

    Monday, September 8, 2008 3:43 PM

Answers

  • User188291263 posted

     Try to add DefaultValue to ControlParameter,because its probably returning Null.

    Also try

    <WhereParameters>

    <asp:ControlParameter ControlID="GridView1" Name="Id"

    PropertyName="SelectedValue" Type="Int32" />

    </WhereParameters>


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 9, 2008 11:53 AM

All replies

  • User-1759624489 posted

     I have tried everything.

     

      <asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableDelete="true" EnableInsert="true" EnableUpdate="true" Where="Id==@Id">
                      <WhereParameters>
                              <asp:ControlParameter ControlID="GridView1" PropertyName="SelectedDataKey" Name="Id" />  
                      </WhereParameters>
                  </asp:LinqDataSource>

     

    It gave me this error:

    Operator '==' incompatible with operand types 'Int32' and 'Object' 

     

    Monday, September 8, 2008 4:21 PM
  • User188291263 posted

     Try to add DefaultValue to ControlParameter,because its probably returning Null.

    Also try

    <WhereParameters>

    <asp:ControlParameter ControlID="GridView1" Name="Id"

    PropertyName="SelectedValue" Type="Int32" />

    </WhereParameters>


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 9, 2008 11:53 AM