I am trying to insertion the records of user and editing their record on the same page . If my query string contains the userid and action text fetch the user records populate the textbox control and change the button text to update.
On button click check the button text if it is update fetch the textboxes texts and fire updation. But the problem is when i update the records in text box and click the button it is fetching the old records instead of the new entered updated record form the textboxes.
In My Index.aspx file
<lable>UserName</lable> <asp:TextBox runat="server" ID="usernamebox" CssClass="form-control"/>
<lable>Email</lable> <asp:TextBox runat="server" ID="emailbox" CssClass="form-control"/>
A table is also on the same page for showing details of users & and anchor tag to edit the record ie
<asp:HyperLink NavigateUrl='<%# Eval("EmployeeID","~/SystemUserForms/Index.aspx?uid={0}&Action=Edit") %>' Text="Edit" runat="server" />
Here is My PageLoad in CodeBehind File
protected void Page_Load(object sender, EventArgs e) {
if (Request.QueryString["uno"]!=null && Request.QueryString["Action"]!=null)
{
string uid= Request.QueryString[0];
string action = Request.QueryString[1];
registerbtn.Text = "Update Records";
CoreModel.Repository.SysUsers S= CoreModel.Repository.UserRepository.getUserByID(Convert.ToInt32(uid));
usernamebox.Text = S.UserName;
emailbox.Text = S.email;
}
}
asp:button control onclick handler is
protected void Register_Users(object sender, EventArgs e)
{
if (Page.IsValid)
{
if(registerbtn.Text="Insert"){
insert()
}else if(registerbtn.Text="Update")
{
string un=usernamebox.Text
string e=emailbox.Text
}
}
}