Click here to Skip to main content
15,886,872 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is my html code
ASP.NET
<div class="form-horizontal">
               <div class="form-group">
                   <label class="col-sm-2 control-label">
                       Roll No <span class="symbol required"></span>
                   </label>
                   <div class="col-sm-3">
                      <asp:DropDownList CssClass="form-control search-select" runat="server" MaxLength="7" ID="ddlRollNo"  />
                      <asp:RequiredFieldValidator ValidationGroup="vgEmployee" runat="server" ID="rfvrOLL" ControlToValidate="ddlRollNo" Required="required"></asp:RequiredFieldValidator>
                    </div>
                   <label class="col-sm-2 control-label">
                       Rank <span class="symbol required"></span>
                   </label>
                   <div class="col-sm-3">
                       <asp:DropDownList CssClass="form-control" ID="ddlRank" runat="server"  />
                       <asp:RegularExpressionValidator runat="server" ID="revddlRank" ControlToValidate="ddlRank" Required="required" Display="Dynamic"></asp:RegularExpressionValidator>
                   </div>
               </div>
               <div class="form-group">
                   <label class="col-sm-2 control-label">
                       Start Date:
                   </label>
                   <div class="col-sm-3">
                       <asp:TextBox ID="txtStartDate" runat="server" MaxLength="10" Required="required" data-date-viewmode="years"
                           CssClass="form-control date-picker" data-date-format="dd-mm-yyyy"></asp:TextBox>
                    </div>
                   <label class="col-sm-2 control-label">
                       Start Time:
                   </label>
                   <div class="input-group input-append bootstrap-timepicker col-sm-3">
                       <input id="txtstartTime" runat="server" type="text" class="form-control time-picker" />
                       <span class="input-group-addon add-on"></span>
                   </div>
                   </div>
               <div class="form-group">
                   <label class="col-sm-2 control-label">
                       End Date:
                   </label>
                   <div class="col-sm-3">
                       <asp:TextBox ID="txtEndDate" runat="server"  Display="Dynamic"
                           CssClass="form-control date-picker" OnTextChanged="txtStartDate_TextChanged" AutoPostBack="true" data-date-viewmode="years" Required="required" MaxLength="10" data-date-format="dd-mm-yyyy"></asp:TextBox>
                      </div>
                   <label class="col-sm-2 control-label">
                       End Time:
                   </label>
                   <div class="input-group input-append bootstrap-timepicker col-sm-3">
                       <input id="txtEndTime" runat="server" type="text" class="form-control time-picker"  />
                       <span class="input-group-addon add-on">^__i class="fa fa-clock-o"></span>
                   </div>
               </div>
               <div class="form-group">
                   <label class="col-sm-2 control-label">
                       Durtion:
                   </label>
                   <div class="col-sm-3">
                       <asp:TextBox CssClass="form-control"  runat="server" ID="txtDurtion" Required="required" />
                       <asp:RegularExpressionValidator runat="server" ID="revDurtion" ControlToValidate="txtDurtion" ></asp:RegularExpressionValidator><br />
                   </div
                       <label class="col-sm-2 control-label">
                       Select Sector:
                   </label>
                   <div class="col-sm-3">
                       <asp:DropDownList CssClass="form-control" ID="ddlSelectSector" runat="server"  />
                       <asp:RegularExpressionValidator runat="server" ID="revSelectSector" ControlToValidate="ddlSelectSector" Required="required" Display="Dynamic"></asp:RegularExpressionValidator>
                   </div>

code behind is:
C#
try
          {
              string[] temp = txtstartTime.Value.Split(new char[] { ' ', ':' });
              DateTime startDate = SafeConvert.ToDateTime(txtStartDate.Text).AddHours(temp[2] == "PM" ? SafeConvert.ToInt32(temp[0]) + 12 : SafeConvert.ToInt32(temp[0]))
                  .AddMinutes(SafeConvert.ToInt32(temp[1]));

              temp = txtEndTime.Value.Split(new char[] { ' ', ':' });
              DateTime endDate = SafeConvert.ToDateTime(txtEndDate.Text).AddHours(temp[2] == "PM" ? SafeConvert.ToInt32(temp[0]) + 12 : SafeConvert.ToInt32(temp[0]))
                  .AddMinutes(SafeConvert.ToInt32(temp[1]));

              EmployeeAbsent empAbsent = new EmployeeAbsent();
              empAbsent.UserName = MyUser.UserName;
              empAbsent.EntryDate = DateTime.Now;
              empAbsent.Emlopyee_Id = ddlRollNo.Text;
              empAbsent.Rank_Id = SafeConvert.ToByte(ddlRank.SelectedValue);
              empAbsent.StartDate = startDate;
              empAbsent.EndDate = endDate;
              empAbsent.Durtion = txtDurtion.Text;
              empAbsent.Sector_Id = SafeConvert.ToByte(ddlSelectSector.SelectedValue);
              _service.InsertEmployeeAbsent(empAbsent);
              _queryStatus = empAbsent.Id > 0;


i want a button on same page which enable the user to edit the last record of that employee.how is it possible using rollno that is primary key
Posted
Updated 30-Dec-14 22:16pm
v2
Comments
[no name] 31-Dec-14 4:23am    
Here you are having a form and where you want to give the edit option for the last record to be updated? Your requirement is not even clear. Specify your requirement clearly.
Sajid227 31-Dec-14 5:26am    
here is asp code of that form where i want to update the details
<label class="col-sm-2 control-label">
Roll No <span class="symbol required"></span>
</label>
<div class="col-sm-3">
<asp:DropDownList CssClass="form-control search-select" runat="server" MaxLength="7" ID="ddlRollNo" OnTextChanged="ddlRollNo_TextChanged" />
<asp:RequiredFieldValidator ValidationGroup="vgEmployee" runat="server" ID="rfvrOLL" ControlToValidate="ddlRollNo" Required="required">
<asp:Button CssClass="btn btn-green btn-block " ID="btn_Click" Width="150" runat="server" CausesValidation="True" Text="UpdateRecord" OnClick="btn_Click_Click"/>

</div>




protected void btn_Click_Click(object sender, EventArgs e)
{
var updateEmp = _service.GetAllEmployeeAbsent().Where(x => x.Emlopyee_Id == ddlRollNo.Text.ToString());


}
[no name] 31-Dec-14 6:30am    
Create a method and fetch the record that you wanted to edit or change and assign the values to the respective controls update the value and resubmit the record using stored procedure.
Sajid227 1-Jan-15 6:18am    
BRO THANX

1 solution

make a function which Select latest Records and fill related control on submit button Click .
please note - apply when data successful insert.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900