Question

It is posible update a row with DetailsView control and Sqldatasource?

Any example?


Edit:

SOLVED

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:BD %>" ProviderName="System.Data.SqlClient" SelectCommand="SELECT Tabla.id, Tabla.nombre FROM Tabla WHERE Tabla.id = 1" UpdateCommand="UPDATE Tabla SET nombre=@nombre WHERE id=@id">
                    <UpdateParameters>
                        <asp:Parameter Name="id" Type="Int32" />
                        <asp:Parameter Name="nombre" Type="String" />
                    </UpdateParameters>
                </asp:SqlDataSource>

                <asp:DetailsView ID="DetailsView1" DefaultMode="Edit" runat="server" Height="50px" Width="125px" DataSourceID="SqlDataSource2" AutoGenerateRows="False" AutoGenerateEditButton="true">

                    <Fields>
                        <asp:TemplateField HeaderText="id">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("id") %>'></asp:TextBox>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="nombre">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("nombre") %>'></asp:TextBox>
                            </EditItemTemplate>
                    </Fields>

                </asp:DetailsView>
Was it helpful?

Solution

yes, it is possible, you can set AutoGenerateEditButton property as true in DetailsView

You better read MSDN documentations related to this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top