2013-02-10 17 views
-4
<asp:GridView ID="grdAttendance1" runat="server" AutoGenerateColumns="False" CellPadding="4" 
         ForeColor="#333333" GridLines="None" Width="100%" HorizontalAlign="Center"> 
         <AlternatingRowStyle BackColor="White" /> 
         <Columns> 
          <asp:BoundField DataField="InstID" HeaderText="College ID" /> 
          <asp:BoundField DataField="Fid" HeaderText="Employee ID" /> 
          <asp:BoundField DataField="FName" HeaderText="Employee Name" /> 
          <asp:BoundField DataField="Designation" HeaderText="Designation" /> 
          <asp:BoundField DataField="Department" HeaderText="Department" /> 
          <asp:BoundField DataField="Date" HeaderText="Date" /> 
          <asp:TemplateField HeaderText="In Time"> 
           <ItemTemplate> 
            <asp:TextBox ID="txtIntime1" runat="server"></asp:TextBox> 
           </ItemTemplate> 
          </asp:TemplateField> 
          <asp:TemplateField HeaderText="Out Time"> 
           <ItemTemplate> 
            <asp:TextBox ID="txtOuttime1" runat="server"></asp:TextBox> 
           </ItemTemplate> 
          </asp:TemplateField> 
          <asp:TemplateField HeaderText="Leave Type"> 
           <ItemTemplate> 
            <asp:TextBox ID="txtLeaveType1" runat="server"></asp:TextBox> 
           </ItemTemplate> 
          </asp:TemplateField> 
         </Columns> 
         <EditRowStyle BackColor="#2461BF" /> 
         <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> 
         <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> 
         <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> 
         <RowStyle BackColor="#EFF3FB" /> 
         <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> 
         <SortedAscendingCellStyle BackColor="#F5F7FB" /> 
         <SortedAscendingHeaderStyle BackColor="#6D95E1" /> 
         <SortedDescendingCellStyle BackColor="#E9EBEF" /> 
         <SortedDescendingHeaderStyle BackColor="#4870BE" /> 
        </asp:GridView> 

我把这个,但它没有绑定与数据库文本框显示空白。我想在网格视图中插入数据库值可编辑文本框,从中我可以更新该文本框

回答

1

首先,我建议浏览Microsoft's ASP.NET data access tutorials

我给你的一般指导,帮助您步入正确的轨道上

  1. 添加一个命令字段是这样的:<asp:CommandField ButtonType=”Link” ShowEditButton=”true” ShowDeleteButton=”true” ShowCancelButton=”true” />
  2. 设置任何您不希望编辑的字段为readonly="true"
  3. 为可编辑的模板字段添加EditItemTemplates
  4. 填写你的事件处理程序,如editindexchanged,更新,删除,编辑,取消等See GV Events here (MSDN)
    • 实现在Row_Updating事件您保存到数据库的代码。

这可能是一个有点棘手,第一次做,但一旦你拥有了它下来这是很容易。

相关问题