空文本框和按钮的ASP.Net详细信息视图 [英] ASP.Net Details view with Empty Textboxes and Button

查看:53
本文介绍了空文本框和按钮的ASP.Net详细信息视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

从一周开始,我一直在满足这一要求,请任何人都可以帮助我.



From a week I am fighting with this requirement,Please can anyone help me.

<asp:DetailsView ID="dview" runat="server" Height="250px" Width="250px" 
            AutoGenerateRows="False" onitemcommand="dview_ItemCommand" DataSourceID="sds1" 
                            EmptyDataText="No records" oniteminserting="dview_ItemInserting">
            
            <Fields>                
                <asp:TemplateField HeaderText="Name">                
                    <ItemTemplate>
                        <asp:TextBox ID="t1" runat="server" Text='<%# Bind("CustomerName") %>'></asp:TextBox>
                    </ItemTemplate>
                    <EditItemTemplate><asp:TextBox ID="t1" runat="server" ></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Address">
                    <ItemTemplate>
                        <asp:TextBox ID="t2" runat="server" Text='<%# Bind("CompanyName") %>'></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>                
                <asp:TemplateField HeaderText="Phone">
                    <ItemTemplate>
                        <asp:TextBox ID="t3" runat="server" Text='<%# Bind("City") %>'></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:ButtonField Text="SAVE" CommandName="InsertButton" />
            </Fields>
            
        </asp:DetailsView>
         <asp:sqldatasource id="sds1"  
          selectcommand="SELECT CustomerName,CompanyName,City from Customers"
          connectionstring="server=localhost;database=Test;integrated security=SSPI"
          runat="server">
        </asp:sqldatasource>




在这里我附加了数据源,所以detailsview以便表中的记录显示在detailsview的文本框中.但是现在我需要显示空的Textbox,以便我可以输入数据,然后单击Save按钮将在文本框中输入的数据保存到数据库中.

您能帮我实现这样的设计吗?

希望您能解决我的问题.




Here I attached datasource so the detailsview so records from table is displaying in the textboxes of detailsview.But now I need to display empty Textboxes so that I can enter the data and then on Clicking SAVE button to save data entered inthe textboxes to the database.

Could you please help me the design to achieve like this.

Hope You got my question.

推荐答案

,您应该使用DetailsView控件,该控件将按需逐行进行演示.
you should use DetailsView control that will give presentation rowwise as you like.
<asp:DetailsView ID="editProfile" runat="server" Height="550px" Width="625px" AutoGenerateRows="false"
          OnItemCommand="editProfile_ItemCommand">
          <Fields>
              <asp:TemplateField HeaderText="Profile Id">
                  <ItemTemplate>
                      <asp:TextBox ID="txtProfileId" runat="server" Text='<%# Bind("Profile_Id") %>' ReadOnly="true"></asp:TextBox>
                  </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="User Id">
                  <ItemTemplate>
                      <asp:TextBox ID="txtUserId" runat="server" Text='<%# Bind("User_Id") %>' ReadOnly="true"></asp:TextBox>
                  </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Name">
                  <ItemTemplate>
                      <asp:TextBox ID="txtUserName" runat="server" Text='<%# Bind("User_Name") %>'></asp:TextBox>
                  </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Mobile No">
                  <ItemTemplate>
                      <asp:TextBox ID="txtMobileNo" runat="server" Text='<%# Bind("Mobile_No") %>'></asp:TextBox>
                  </ItemTemplate>
              </asp:TemplateField>
              <asp:ButtonField Text="Update Profile" CommandName="updateButton" />
          </Fields>
          <HeaderTemplate>
              <%# Eval("User_Id") %>
          </HeaderTemplate>
      </asp:DetailsView>


现在,在detailsview的ItemCommand事件上,找到按钮并执行任务.


Now on ItemCommand event of detailsview find the button and perform task.


这篇关于空文本框和按钮的ASP.Net详细信息视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆