StoredProcedure:
ALTER proc [dbo].[proc_del]
(@UserName varchar(50),@ResultMessage varchar(50) output)
as
begin
delete from reg_plannIT where UserName=@UserName
set @ResultMessage='Sucess'
end
DataObjects:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RegFields
{
public class Fields
{
public string EmployeeName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string ConfirmPassword { get; set; }
public string EmailId { get; set; }
public string PhoneNo { get; set; }
public string Address { get; set; }
}
}
DAOLayer:
public string UpGridDB(Fields fs)
{
try
{
string retval = "";
SqlParameter[] para = new SqlParameter[3];
para[0] = new SqlParameter("@UserName", fs.UserName);
para[1] = new SqlParameter("@EmployeeName", fs.EmployeeName);
para[2] = new SqlParameter("@ResultMessage", SqlDbType.VarChar, 500);
SqlHelper.ExecuteNonQuery(connection, CommandType.StoredProcedure, "up_proc", para);
retval = para[2].Value.ToString();
return retval;
}
catch (Exception ex)
{
throw ex;
}
}
Controllers:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RegFields;
using DataBase;
namespace Reg
{
public class GridUpdateGrid
{
private Fields fsctrl = new Fields();
public Fields fieldsCtrl
{
get
{
return fsctrl;
}
set
{
value = fsctrl;
}
}
private Data dctrl = new Data();
public string UpGridCtrl()
{
return dctrl.UpdateData(this.fieldsCtrl);
}
}
}
DataConnection:
public static string connection
{
get
{
return ConfigurationManager.AppSettings.Get("ravi");
}
DataLayer:
public string UpdateData(Fields fsdata)
{
return bh.UpGridDB(fsdata);
}
UI
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ExampleToGridAll.aspx.cs"
Inherits="ExampleToGridAll" %>
CodeBehind:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox t1;
TextBox t2;
t1 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtUName");
t2 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtEName");
// I tried in both the ways but im unabel to get,so could any one forrward the code for this
//t1 = (TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0];
//t2 = (TextBox)GridView1.Rows[e.RowIndex].Cells[0].Controls[0];
guc.fieldsCtrl.UserName = t1.Text;
guc.fieldsCtrl.EmployeeName = t2.Text;
guc.UpGridCtrl();
GetData();
Response.Write("Sucess");
}
Replies
Know the answer? Post it — somebody with the same question will find it here.