I have a Repeater displaying rows from an SQL Server database.
I have an Edit and Delete button appearing in each row, but I can't successfully write code behind these buttons.
Here is the code to display the repeater:
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<div>
<table>
<tr><th><%#Eval("Event_Title")%></th><td><asp:Button ID="LinkButton1" runat="server" CommandName="Edit" Text="Edittttt"></asp:Button></td><td><button>Delete</button></td></tr>
<tr><td>Event Group ID</td><td><%#Eval("Event_Group_Id") %></td></tr>
<tr><td>Event Type</td><td><%#Eval("Event_Type") %></td></tr>
<tr><td>Event ID</td><td><%#Eval("Event_Id") %></td></tr>
<br />
</table>
</div>
</ItemTemplate>
</asp:Repeater>
And here is the UI.
I have tried to use the below code to see if the Edit button is working:
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch (e.CommandName)
{
case "Edit":
Response.Write("Edit button clicked");
break;
default: break;
}
}
But I am getting this error message:
Invalid postback or callback argument. Event validation is enabled using in configuration or <%# Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Below is my Page_Load code:
I understand that a lot of it is duplicated, but I will tidy this up in time. Can anyone advise me what I need to do?
//Trying to display events using repeater
SqlConnection connR;
string connectionStringR = ConfigurationManager.ConnectionStrings[
"BallinoraDBConnectionString1"].ConnectionString;
connR = new SqlConnection(connectionStringR);
SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM Events", connR);
DataTable dt = new DataTable();
sda.Fill(dt);
Repeater1.DataSource = dt;
Repeater1.DataBind();
Response.Write("Hello");
SqlConnection conn;
SqlCommand comm;
string connectionString = ConfigurationManager.ConnectionStrings[
"BallinoraDBConnectionString1"].ConnectionString;
conn = new SqlConnection(connectionString);
comm = new SqlCommand( //where Event_Group = 'Upcoming
"SELECT Event_Id, Event_Group_Id, Event_Type, Event_Title FROM Events WHERE Event_Group_Id = 1",
conn);
conn.Open();
SqlDataReader reader = comm.ExecuteReader();
if (lblGroupOneEvents.Text == "")
{
while (reader.Read())
{
lblGroupOneEvents.Text += "<div> <table> <tr><td>" + reader["Event_Title"] + "</td>" + "</tr><tr><td><button>Delete</button></td></tr></table> </div>";
}
// lblTest.Text += reader["Event_Id"] +"<br />";
}
else
{
;
}
reader.Close();
conn.Close();
SqlConnection conn1;
SqlCommand comm1;
string connectionString1 = ConfigurationManager.ConnectionStrings[
"BallinoraDBConnectionString1"].ConnectionString;
conn1 = new SqlConnection(connectionString);
comm1 = new SqlCommand( //where Event_Type = 'Upcoming
"SELECT Event_Id, Event_Group_Id, Event_Type, Event_Title FROM Events WHERE Event_Group_Id = 2",
conn);
conn.Open();
SqlDataReader reader1 = comm1.ExecuteReader();
while (reader1.Read())
{
lblGroupTwoEvents.Text += reader1["Event_Title"] + "<br />";
// lblGroupTwoEventsType.Text += reader1["Event_Id"] + "<br />";
}
reader.Close();
conn.Close();
Related
I don't get on well with post back/DDL's.. yes I have used autopostback = true!
Below, I am trying to get the selected index changed... to fire on budgetDDL1 however, whatever I try it doesn't!
I'm binding data from a DB to the ddl...
I've tried binding/adding the ddl to the table inside/outside the post backs and enabling/disabling the view states etc.. none of this works.. there must be an easy answer?!
In what order do I need to create/bind the dropdowns for the index changed method to fire an explanation would be useful too!
DropDownList budgetDDL1 = new DropDownList();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string QueryString = "SELECT [BudgetCode], [Department], CONCAT([BudgetCode],' - ', [Department]) AS 'textvalue' FROM [tblBudget]";
using (SqlConnection myConnection = new SqlConnection(ConnectionString))
{
using (SqlCommand cmd = new SqlCommand(QueryString, myConnection))
{
myConnection.Open();
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
DataTable dt = new DataTable();
dt.Load(dr);
budgetDDL1.SelectedIndex = 0;
budgetDDL1.DataSource = dt;
budgetDDL1.DataTextField = "textvalue";
budgetDDL1.DataValueField = "BudgetCode";
budgetDDL1.AutoPostBack = true;
budgetDDL1.SelectedIndexChanged += budgetDDL1_SelectedIndexChanged;
budgetDDL1.DataBind();
}
}
}
table1.Controls.Add(budgetDDL1);
}
protected void budgetDDL1_SelectedIndexChanged(object sender, EventArgs e)
{ *I have a breakpoint here which doesn't fire*
string msg = budgetDDL1.SelectedItem.Text;
ScriptManager.RegisterClientScriptBlock(sender as System.Web.UI.Control, this.GetType(), "alert", "alert('" + msg + "')", true);
}
view:
<body>
<form runat="server">
<table>
<tr>
<td id="table1" runat="server">
</td>
</tr>
</table>
</form>
</body>
Place auto post back code out side of the !IsPostback
DropDownList budgetDDL1 = new DropDownList();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string QueryString = "SELECT [BudgetCode], [Department], CONCAT([BudgetCode],' - ', [Department]) AS 'textvalue' FROM [tblBudget]";
using (SqlConnection myConnection = new SqlConnection(ConnectionString))
{
using (SqlCommand cmd = new SqlCommand(QueryString, myConnection))
{
myConnection.Open();
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
DataTable dt = new DataTable();
dt.Load(dr);
budgetDDL1.SelectedIndex = 0;
budgetDDL1.DataSource = dt;
budgetDDL1.DataTextField = "textvalue";
budgetDDL1.DataValueField = "BudgetCode";
}
}
}
budgetDDL1.AutoPostBack = true;
budgetDDL1.SelectedIndexChanged += budgetDDL1_SelectedIndexChanged;
budgetDDL1.DataBind();
table1.Controls.Add(budgetDDL1);
}
Dynamic controls should be added on Init. After OnLoad finishes executing ASP.NET starts processing control's events and values. You can read/write their properties on or after Load.
Suggest you to check the place where you have created DropDownList.
Answer: because you have created DropDownList after the events have been processed.
Have a look here: https://web.archive.org/web/20210330142645/http://www.4guysfromrolla.com/articles/092904-1.aspx
I have an existing code that displays a reportserver RDL report in a reportviewer. I prompt the user for inputs and those are then passed as parameters to a store procedure in Sql Server.
The report generates properly as proof of concept with hard-coded number of textboxes, but obviously not all reports will have the same number of parameters. So here is my working code and the screenshot:
Working Report
ASP.NET
<%# Page Language="C#" Trace="true" AutoEventWireup="true" CodeBehind="Reports.aspx.cs" Inherits="FormsAuthAd.Reports" %>
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" class="reports-body">
<head runat="server">
<title>Reports</title>
<link href="../css/Style.css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div class="params-container container">
<asp:TextBox ID="txtStart" runat="server" placeholder="From Date" class="input-fields"></asp:TextBox>
<asp:TextBox ID="txtEnd" runat="server" placeholder="To Date" class="input-fields"></asp:TextBox>
<asp:TextBox ID="txtBrand" runat="server" placeholder="Brand" class="input-fields"></asp:TextBox>
<asp:TextBox ID="txtSeason" runat="server" placeholder="Season" class="input-fields"></asp:TextBox>
<asp:TextBox ID="txtComp" runat="server" placeholder="Company" class="input-fields"></asp:TextBox>
<asp:TextBox ID="txtLoc" runat="server" placeholder="Location" class="input-fields"></asp:TextBox>
<asp:TextBox ID="txtLine" runat="server" placeholder="Line" class="input-fields"></asp:TextBox>
<asp:Button ID="btnShow" runat="server" OnClick="Button1_Click" Text="Generate" class="input-fields"/>
</div>
<div class="rpt-container container">
<rsweb:ReportViewer ID="rptVwr" runat="server" CssClass="rpt-viewer"></rsweb:ReportViewer>
</div>
</form>
</body>
</html>
CODE BEHIND
private void showReport()
{
rptVwr.Reset();
DataTable dt = GetData(txtStart.Text, txtEnd.Text, txtBrand.Text, txtSeason.Text, txtComp.Text, txtLoc.Text);
rptVwr.Visible = true;
ReportDataSource rds = new ReportDataSource("DataSet2", dt);
rptVwr.LocalReport.DataSources.Add(rds);
rptVwr.LocalReport.ReportPath = "../ReportServer/StockExport.rdl";
ReportParameter[] rptParams = new ReportParameter[]
{
new ReportParameter("StartDate",txtStart.Text),
new ReportParameter("EndDate",txtEnd.Text),
new ReportParameter("Brand",txtBrand.Text),
new ReportParameter("Season",txtSeason.Text),
new ReportParameter("Company",txtComp.Text),
new ReportParameter("Store",txtLoc.Text),
};
rptVwr.LocalReport.SetParameters(rptParams);
rptVwr.LocalReport.Refresh();
}
private DataTable GetData(string fromDate, string toDate, string brandCode, string seasonCode, string compCode, string locCode)
{
DataTable dt = new DataTable();
string connStr = System.Configuration.ConfigurationManager.ConnectionStrings ["ReportServerConnStr"].ConnectionString;
using (SqlConnection cn = new SqlConnection(connStr))
{
SqlCommand cmd = new SqlCommand("sp_valueEntryStock", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("#StartDate", SqlDbType.NVarChar).Value = fromDate;
cmd.Parameters.Add("#EndDate", SqlDbType.NVarChar).Value = toDate;
cmd.Parameters.Add("#Season", SqlDbType.NVarChar).Value = seasonCode;
cmd.Parameters.Add("#Brand", SqlDbType.NVarChar).Value = brandCode;
cmd.Parameters.Add("#Company", SqlDbType.NVarChar).Value = compCode;
cmd.Parameters.Add("#Store", SqlDbType.NVarChar).Value = locCode;
cmd.CommandTimeout = 1000;
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(dt);
}
return dt;
}
protected void Button1_Click(object sender, EventArgs e)
{
showReport();
}
Obviously, I did not want a hard-coded number of textboxes so I tweaked my code to dynamically add textboxes on page load based on a table in Sql Server.Here is my existing code and screenshot:
Page after submitting parameters
CODE BEHIND
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(connStr))
{
using (SqlCommand cmd = new SqlCommand("SELECT [FieldNum],[FieldName],[AspId],[SqlParameter] FROM [MIS_FieldsMaster]", con))
{
cmd.CommandType = CommandType.Text;
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(dtable);
int i = 0;
foreach (DataRow dr in dtable.Rows)
{
TextBox tb = new TextBox();
tb.ID = dr["AspId"].ToString().Trim();
stringArray[i] = dr["SqlParameter"].ToString().Trim();
tb.Text = stringArray[i];
ph1.Controls.Add(tb);
i++;
}
}
}
}
private void showReport()
{
rptVwr.Reset();
DataTable dt = GetData();
rptVwr.Visible = true;
ReportDataSource rds = new ReportDataSource("DataSet2", dt);
rptVwr.LocalReport.DataSources.Add(rds);
rptVwr.LocalReport.ReportPath = "../ReportServer/StockExport.rdl";
rptVwr.LocalReport.Refresh();
}
private DataTable GetData()
{
DataTable dt = new DataTable();
int i = 0;
string connStr = System.Configuration.ConfigurationManager.ConnectionStrings["ReportServerConnStr"].ConnectionString;
using (SqlConnection cn = new SqlConnection(connStr))
{
SqlCommand cmd = new SqlCommand("sp_valueEntryStock", cn);
cmd.CommandType = CommandType.StoredProcedure;
foreach (TextBox textBox in ph1.Controls.OfType<TextBox>())
{
cmd.Connection = cn;
cmd.Parameters.AddWithValue("#" + stringArray[i], textBox.Text);
i++;
}
cmd.CommandTimeout = 1000;
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(dt);
}
return dt;
}
protected void Button1_Click(object sender, EventArgs e)
{
showReport();
}
So it does not even show me any error message so I do not really know where to look. I debugged the new code and I believe it is retrieving the data in the stored procedure because the local variable shows rows retrieved under datatable dt. The only thing is the report does not show in the reportViewer. It does not even show report toolbars.
Row retrieved from datatable dt
I would greatly appreciate any help. Thanks.
I figured out the reason for the report not displaying in the reportviewer.
It seems that I still need to add the parameters and set it to the reportviewer, like in my first working code:
ReportParameter[] rptParams = new ReportParameter[]
{
new ReportParameter("StartDate",txtStart.Text),
new ReportParameter("EndDate",txtEnd.Text),
new ReportParameter("Brand",txtBrand.Text),
new ReportParameter("Season",txtSeason.Text),
new ReportParameter("Company",txtComp.Text),
new ReportParameter("Store",txtLoc.Text),
};
rptVwr.LocalReport.SetParameters(rptParams);
Obviously =, it still needs to be dynamic so here is the code that I used:
List<ReportParameter> paramList = new List<ReportParameter>();
int i = 0;
foreach (TextBox textBox in ph1.Controls.OfType<TextBox>())
{
paramList.Add(new ReportParameter(stringArray[i], textBox.Text));
i++;
}
rptVwr.LocalReport.SetParameters(paramList);
Now, I am able to generate the dynamic textboxes and at the same time pass the values in those textboxes to my sql server stored procedure and finally generate and display the report based on the same textboxes.
I would consider this solved, but I just have a niggling question in my head:
Why didn't my code work when it is exactly the same (at least logically if not syntactically) as the code in the youtube example that I took: Two way to pass parameter in stored procedure and display the output in Report Viewer using C#
I am working in a project where i need to list the database child items in listview2 who's parent items reside in listview1 already. here is my listview1 code;
<asp:ListView
ID="ListView1"OnSelectedIndexChanged="ListView1_SelectedIndexChanged" runat="server">
<ItemTemplate>
<a href='<%# Eval("Module_Redirect") %>'> <img src="<%#
Eval("Module_img") %>" /> </a>
</ItemTemplate>
the .cs page code is as follow(which is not working yet!)
protected void ListView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.ListView1.SelectedIndex == 3)
{
SqlDataAdapter da2 = new SqlDataAdapter();
da2.SelectCommand = new SqlCommand("select * from tbl_Forms where Module_ID=3 ", conn);
DataTable dt2= new DataTable();
da2.Fill(dt2);
ListView2.DataSource = dt2;
ListView2.DataBind();
}
}
My point is: how can in fetch the selected item templete of listview1 and show the relevent record in listview2?
you can try this.
using (SqlConnection con = new SqlConnection("YourConnectioString"))
{
using (SqlDataAdapter da2 = new SqlDataAdapter { SelectCommand = new SqlCommand("select * from tbl_Forms where Module_ID = #Module_ID ", con) })
{
// as your using index as the parameter,,
da2.SelectCommand.Parameters.AddWithValue("#Module_ID", ListView1.SelectedIndex);
// or if your trying to pass parameter Module_ID from ListView1 DataKey ,, you can use SelectedDataKey
//da2.SelectCommand.Parameters.AddWithValue("#Module_ID", ListView1.SelectedDataKey);
using (DataTable dt2 = new DataTable())
{
con.Open();
da2.Fill(dt2);
ListView2.DataSource = dt2;
ListView2.DataBind();
}
}
}
Im having a problem with a dropdownlist in asp.net.
When i try to get the selected value of the list it doesnt return anything.
The aspx looks like this
<div class="form-signin">
<h2 class="form-signin-heading">Slet besked</h2>
<div class="input-group">
<span class="input-group-addon">ID</span>
<asp:dropDownList runat="server" CssClass="form-control" ID="sletBox" />
</div>
<asp:Button runat="server" CssClass="btn btn-lg btn-block btn-danger" Text="Slet" OnClick="Slet" />
</div>
And the kode behind it looks like this
protected void Slet(object sender, EventArgs e)
{
Response.Write("wow der sker noget");
Response.Write(sletBox.SelectedItem.Value);
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection myconnection = new SqlConnection();
SqlCommandBuilder cmdBuilder = new SqlCommandBuilder();
myconnection.ConnectionString = constr;
myconnection.Open();
string sqlcmd = "DELETE FROM messages WHERE messageid = '" + sletBox.SelectedValue.ToString() + "'";
SqlCommand messageDelete = new SqlCommand(sqlcmd, myconnection);
messageDelete.ExecuteNonQuery();
myconnection.Close();
}
The only thing that works is the response.write(wow) not the selectedvalue
EDIT:
The page_load code
protected void Page_Load(object sender, EventArgs e)
{
DataTable subjects = new DataTable();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
{
SqlDataAdapter adapter = new SqlDataAdapter("SELECT messageId, messageText FROM messages", con);
adapter.Fill(subjects);
sletBox.DataSource = subjects;
sletBox.DataTextField = "messageText";
sletBox.DataValueField = "messageId";
sletBox.DataBind();
}
sletBox.Items.Insert(0, new ListItem("Vælg besked", ""));
}
You're doing the databinding for the dropdownlist in the pageload and not checking for IsPostBack. As a result when the button triggers the clik it resets the selectedvalue. Change you PageLoad like below
if (!IsPostBack)
{
DataTable subjects = new DataTable();
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString)
{
SqlDataAdapter adapter = new SqlDataAdapter("SELECT messageId, messageText FROM messages", con);
adapter.Fill(subjects);
sletBox.DataSource = subjects;
sletBox.DataTextField = "messageText";
sletBox.DataValueField = "messageId";
sletBox.DataBind();
}
sletBox.Items.Insert(0, new ListItem("Vælg besked", ""));
}
As a side note as Mathew suggested try adding using to better manage your connections objects so it's properly disposed after it's been used.
You must load your DropDownList data only if IsPostBack is false, otherwise you'll be reloading the control every postback. Once the data bound to the control is changed, the selected value is lost as well. Keep in mind that the Page_Load event is fired when the SelectedIndexChanged event occurs.
if(!Page.IsPostBack)
{
DataTable subjects = new DataTable();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
{
SqlDataAdapter adapter = new SqlDataAdapter("SELECT messageId, messageText FROM messages", con);
adapter.Fill(subjects);
sletBox.DataSource = subjects;
sletBox.DataTextField = "messageText";
sletBox.DataValueField = "messageId";
sletBox.DataBind();
}
sletBox.Items.Insert(0, new ListItem("Vælg besked", ""));
}
I am populating a DropDownList from a SQL Server database as shown below. It works fine, but I'm not sure it's a good way. Can someone shed some light on this method, and give some improvements?
private void LoadSubjects()
{
ddlSubjects.Items.Clear();
string selectSQL = "SELECT SubjectID,SubjectName FROM Students.dbo.Subjects";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(selectSQL, con);
SqlDataReader reader;
try
{
ListItem newItem = new ListItem();
newItem.Text = "<Select Subject>";
newItem.Value = "0";
ddlSubjects.Items.Add(newItem);
con.Open();
reader = cmd.ExecuteReader();
while (reader.Read())
{
newItem = new ListItem();
newItem.Text = reader["SubjectName"].ToString();
newItem.Value = reader["SubjectID"].ToString();
ddlSubjects.Items.Add(newItem);
}
reader.Close();
}
catch (Exception err)
{
//TODO
}
finally
{
con.Close();
}
}
You could bind the DropDownList to a data source (DataTable, List, DataSet, SqlDataSource, etc).
For example, if you wanted to use a DataTable:
ddlSubject.DataSource = subjectsTable;
ddlSubject.DataTextField = "SubjectNamne";
ddlSubject.DataValueField = "SubjectID";
ddlSubject.DataBind();
EDIT - More complete example
private void LoadSubjects()
{
DataTable subjects = new DataTable();
using (SqlConnection con = new SqlConnection(connectionString))
{
try
{
SqlDataAdapter adapter = new SqlDataAdapter("SELECT SubjectID, SubjectName FROM Students.dbo.Subjects", con);
adapter.Fill(subjects);
ddlSubject.DataSource = subjects;
ddlSubject.DataTextField = "SubjectNamne";
ddlSubject.DataValueField = "SubjectID";
ddlSubject.DataBind();
}
catch (Exception ex)
{
// Handle the error
}
}
// Add the initial item - you can add this even if the options from the
// db were not successfully loaded
ddlSubject.Items.Insert(0, new ListItem("<Select Subject>", "0"));
}
To set an initial value via the markup, rather than code-behind, specify the option(s) and set the AppendDataBoundItems attribute to true:
<asp:DropDownList ID="ddlSubject" runat="server" AppendDataBoundItems="true">
<asp:ListItem Text="<Select Subject>" Value="0" />
</asp:DropDownList>
You could then bind the DropDownList to a DataSource in the code-behind (just remember to remove:
ddlSubject.Items.Insert(0, new ListItem("<Select Subject>", "0"));
from the code-behind, or you'll have two "" items.
I hope I am not overstating the obvious, but why not do it directly in the ASP side? Unless you are dynamically altering the SQL based on certain conditions in your program, you should avoid codebehind as much as possible.
You could do the above all in ASP directly without code using the SqlDataSource control and a property in your dropdownlist.
<asp:GridView ID="gvSubjects" runat="server" DataKeyNames="SubjectID" OnRowDataBound="GridView_RowDataBound" OnDataBound="GridView_DataBound">
<Columns>
<asp:TemplateField HeaderText="Subjects">
<ItemTemplate>
<asp:DropDownList ID="ddlSubjects" runat="server" DataSourceID="sdsSubjects" DataTextField="SubjectName" DataValueField="SubjectID">
</asp:DropDownList>
<asp:SqlDataSource ID="sdsSubjects" runat="server"
SelectCommand="SELECT SubjectID,SubjectName FROM Students.dbo.Subjects"></asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
public void getClientNameDropDowndata()
{
getConnection = Connection.SetConnection(); // to connect with data base Configure manager
string ClientName = "Select ClientName from Client ";
SqlCommand ClientNameCommand = new SqlCommand(ClientName, getConnection);
ClientNameCommand.CommandType = CommandType.Text;
SqlDataReader ClientNameData;
ClientNameData = ClientNameCommand.ExecuteReader();
if (ClientNameData.HasRows)
{
DropDownList_ClientName.DataSource = ClientNameData;
DropDownList_ClientName.DataValueField = "ClientName";
DropDownList_ClientName.DataTextField="ClientName";
DropDownList_ClientName.DataBind();
}
else
{
MessageBox.Show("No is found");
CloseConnection = new Connection();
CloseConnection.closeConnection(); // close the connection
}
}
((TextBox)GridView1.Rows[e.NewEditIndex].Cells[3].Controls[0]).Enabled = false;