Updating boolean value in database - c#

I have a button on my asp.net webpage which I have coded to read the value of a boolean column in an access database on pageload and what the button does changes according to whether the value of the column is true or false.
Essentially this button is a show/hide button for a product (click it to hide the product, or if already hidden click it to make it visible).
I'm getting some strange behavior as when the product is hidden, clicking to make the product visible works (updates the database), however, hiding it does not and I can't work out why one would work but the other wouldn't.
Code is as follows:
if (!IsPostBack)
try
{
s = WebConfigurationManager.ConnectionStrings["LNDatabase"].ConnectionString;
conn = new OleDbConnection(s);
cmd = new OleDbCommand("SELECT * FROM products WHERE products.prod_id = #test", conn);
OleDbParameter test = new OleDbParameter("#test", OleDbType.Integer);
test.Value = Request.QueryString["prod_id"];
cmd.Parameters.Add(test);
conn.Open();
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
dr.Read();
title.Text = dr["shortdesc"].ToString();
description.Text = dr["longdesc"].ToString();
price.Text = dr["price"].ToString();
productcat = dr["cat"].ToString();
product_live = dr["live"].ToString();
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
finally
{
dr.Close();
conn.Close();
}
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
{
bool prod_live_bool = Convert.ToBoolean(product_live);
if (prod_live_bool == true)
{
live_label.Text = "This product is visible to customers";
livelabelbutton.Text = "Hide this product";
livelabelbutton.Click += new EventHandler(this.hideproduct_click);
}
else
{
live_label.Text = "This product is not visible to customers";
livelabelbutton.Text = "Make this product visible";
livelabelbutton.Click += new EventHandler(this.showproduct_click);
}
}
protected void hideproduct_click(object sender, EventArgs e)
{
string prodid = Request.QueryString["prod_id"];
s = WebConfigurationManager.ConnectionStrings["LNDatabase"].ConnectionString;
string str = "UPDATE products SET live = #hide WHERE prod_id=#product";
using (OleDbConnection conn = new OleDbConnection(s))
{
using (OleDbCommand cmd = new OleDbCommand(str, conn))
{
OleDbCommand mycommand = new OleDbCommand();
OleDbParameter hideparam = new OleDbParameter("#hide", OleDbType.Boolean);
hideparam.Value = false;
cmd.Parameters.Add(hideparam);
OleDbParameter product = new OleDbParameter("#product", OleDbType.VarChar);
product.Value = prodid;
cmd.Parameters.Add(product);
conn.Open();
cmd.ExecuteNonQuery();
}
}
Response.Redirect(Request.RawUrl);
}
protected void showproduct_click(object sender, EventArgs e)
{
string prodid = Request.QueryString["prod_id"];
s = WebConfigurationManager.ConnectionStrings["LNDatabase"].ConnectionString;
string str = "UPDATE products SET live = #show WHERE prod_id=#product";
using (OleDbConnection conn = new OleDbConnection(s))
{
using (OleDbCommand cmd = new OleDbCommand(str, conn))
{
OleDbCommand mycommand = new OleDbCommand();
OleDbParameter hideparam = new OleDbParameter("#show", OleDbType.Boolean);
hideparam.Value = true;
cmd.Parameters.Add(hideparam);
OleDbParameter product = new OleDbParameter("#product", OleDbType.VarChar);
product.Value = prodid;
cmd.Parameters.Add(product);
conn.Open();
cmd.ExecuteNonQuery();
}
}
Response.Redirect(Request.RawUrl);
}
Sorry for the long code.

If the point of the command button is to toggle the value of the [live] Yes/No field, let the db engine do what you need.
UPDATE products SET live = (Not live) WHERE prod_id=#product
Not returns the inverse of a Boolean value. So Not True returns False and Not False returns True. Therefore the UPDATE statement sets live to the inverse of whatever it contained before executing the UPDATE. Try it in an Access session as a new query to examine how it operates.
If that is satisfactory, you wouldn't need separate routines for hide and show.

Related

Refresh DataGridView after inserting values

I have established connection and inserted values into the table.
However, I am not sure the best method to refresh the DataGridview as the values have been inserted after click button.
private void button1_Click(object sender, EventArgs e)
{
{
string theText = makeTextBox.Text;
string theText2 = modelTextBox.Text;
var value = Convert.ToInt32(yearTextBox.Text);
int i = 6;
cnn.Open();
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "INSERT INTO cars(Make,Model,Year) VALUES(#Make,#Model,#Year)";
cmd.Prepare();
cmd.Parameters.AddWithValue("#Make", theText);
cmd.Parameters.AddWithValue("#Model", theText2);
cmd.Parameters.AddWithValue("#Year", value);
cmd.ExecuteNonQuery();
{
}
dataGridView1.DataSource = carsBindingSource;
dataGridView1.Refresh();
cnn.Close();
}
}
}
}
enter image description here
EDIT:
here is the code with the working solution of rebinding the datasource and then it will update:
{
string theText = textBox1.Text;
string theText2 = textBox2.Text;
var value = Convert.ToInt32(textBox3.Text);
int i = 6;
cnn.Open();
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "INSERT INTO cars(Make,Model,Year) VALUES(#Make,#Model,#Year)";
cmd.Prepare();
cmd.Parameters.AddWithValue("#Make", theText);
cmd.Parameters.AddWithValue("#Model", theText2);
cmd.Parameters.AddWithValue("#Year", value);
cmd.ExecuteNonQuery();
{
}
cnn.Close();
carsBindingSource = new BindingSource();
carsBindingSource.DataSource = carsTableAdapter.GetData();
dataGridView2.DataSource = carsBindingSource;
}
}```
Your code is missing the part where the carsBindingSource variable is initialized with data. From your limited code, it should be noted that… if you add/insert a new row into the table in the data base, then this is NOT going to automatically update the carsBindingSource.
It is unknown “what” is used as a DataSource to the carsBindingSource. OR, how this data source is populated. I will assume the DataSource to the BindingSource is a DataTable and that somewhere in the code it is getting this DataTable from a query to the data base. If this process is not already in a single method that returns a DataTable, then, I recommend you create one, and it may look something like…
private DataTable GetCarsDT() {
DataSet ds = new DataSet();
string connString = "Server = localhost; Database = CarsDB; Trusted_Connection = True;";
try {
using (SqlConnection conn = new SqlConnection(connString)) {
conn.Open();
using (SqlCommand command = new SqlCommand()) {
command.Connection = conn;
command.CommandText = "SELECT * FROM Cars";
using (SqlDataAdapter da = new SqlDataAdapter(command)) {
da.Fill(ds, "Cars");
return ds.Tables[0];
}
}
}
}
catch (Exception ex) {
MessageBox.Show("DBError:" + ex.Message);
}
return null;
}
Above will return a DataTable with three (3) columns, Make, Model and Year. This DataTable is used as a DataSource to the BindingSource… carsBindingBource.
Now in the button1_Click event, the code inserts the new values into the data base. However, the carsBindingSource will still contain the data “before” the new items were added to the DB. Therefore, we can simply use the method above to “update” the carsBindingSource after the new items are added to the DB.
Note: you can go two routs here, 1) as described above, simply update “all” the data in the binding source… OR … 2) after updating the new items into the data base, you can also add the new items to the binding source’s data source… i.e. its DataTable. Either way will work and unless there is a large amount of data, I do not think one way would be preferred over the other.
Below shows what is described above. Note, the commented code adds the new items directly to the DataTable. You can use either one but obviously not both.
private void button1_Click(object sender, EventArgs e) {
string connString = "Server = localhost; Database = CarsDB; Trusted_Connection = True;";
try {
using (SqlConnection conn = new SqlConnection(connString)) {
conn.Open();
using (SqlCommand command = new SqlCommand()) {
command.Connection = conn;
command.CommandText = "INSERT INTO cars(Make,Model,Year) VALUES(#Make,#Model,#Year)";
command.Parameters.Add("#Make", SqlDbType.NChar, 50).Value = makeTextBox.Text.Trim();
command.Parameters.Add("#Model", SqlDbType.NChar, 50).Value = modelTextBox.Text.Trim();
int.TryParse(yearTextBox.Text.Trim(), out int year);
command.Parameters.Add("#Year", SqlDbType.Int).Value = year;
command.ExecuteNonQuery();
carsBindingSource.DataSource = GetCarsDT();
//DataTable dt = (DataTable)carsBindingSource.DataSource;
//dt.Rows.Add(makeTextBox.Text.Trim(), modelTextBox.Text.Trim(), year);
}
}
}
catch (Exception ex) {
MessageBox.Show("DBError:" + ex.Message);
}
}
Putting all this together…
BindingSource carsBindingSource;
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
carsBindingSource = new BindingSource();
carsBindingSource.DataSource = GetCarsDT();
dataGridView1.DataSource = carsBindingSource;
}
Hope this makes sense.
I dont think its possible. You may need to create a separate button to submit and then refresh the data

Cannot set the SelectedValue in a ListControl with an empty ValueMember in winform using c#

I have a combobox that loads data from database but i got an error that you cannot set the selectedValue in a ListControl Although i have set the selectValue to a Primary key of a Table. But still getting error on runtime.. Here is the Code..
private void FormAddStudent_Load(object sender, EventArgs e)
{
//For combobox Campuse
cBoxCampus.DataSource = GetAllCampuses();
cBoxCampus.DisplayMember = "campus_name";
cBoxCampus.SelectedValue = "campus_id";
//Foe ComboBox Department
cBoxDepartment.DataSource = GetAllDepartment();
cBoxDepartment.DisplayMember = "depname";
cBoxDepartment.SelectedValue = "depid";
}
and this is the code behind Insert Button
private void btnInsert_Click(object sender, EventArgs e)
{
string CS = ConfigurationManager.ConnectionStrings["UMSdbConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
con.Open();
SqlCommand cmd = new SqlCommand("SELECT ISNULL(MAX(std_id),0)+1 FROM Student", con);
cmd.CommandType = CommandType.Text;
tbID.Text = cmd.ExecuteScalar().ToString();
{
using (SqlCommand cmd1 = new SqlCommand("INSERT INTO Student (std_id,std_name,std_f_name,std_mob,std_gender,std_cnic,std_campus,std_dep,std_address,std_batch,std_batch_year)VALUES(#std_id,#std_name,#std_f_name,#std_mob,#std_gender,#std_cnic,#std_campus,#std_dep,#std_address,#std_batch,#std_batch_year)VALUES(#campus_id,#campus_name)", con))
{
cmd1.CommandType = CommandType.Text;
cmd1.Parameters.AddWithValue("#std_id", tbID.Text);
cmd1.Parameters.AddWithValue("#std_name", tbName.Text);
cmd1.Parameters.AddWithValue("#std_f_name", tbFatherName.Text);
cmd1.Parameters.AddWithValue("#std_mob", tbMobNumber.Text);
cmd1.Parameters.AddWithValue("#std_gender", GetGender());
cmd1.Parameters.AddWithValue("#std_cnic", tbMobNumber.Text);
cmd1.Parameters.AddWithValue("#std_campus",(cBoxCampus.SelectedIndex == -1) ? 0: cBoxCampus.SelectedValue);
cmd1.Parameters.AddWithValue("#std_dep", (cBoxDepartment.SelectedIndex == -1) ? 0 : cBoxDepartment.SelectedValue);
cmd1.Parameters.AddWithValue("#std_address", tbAddress.Text);
cmd1.Parameters.AddWithValue("#std_batch", tbBatchNo.Text);
cmd1.Parameters.AddWithValue("#std_batch_year", tbBatchYear.Text);
cmd1.ExecuteNonQuery();
con.Close();
MessageBox.Show("Record Saved");
}
}
}
}
Replace
cBoxCampus.SelectedValue = "campus_id";
With ListControl.ValueMember Property
cBoxCampus.ValueMember = "campus_id";
Do similar operation for cBoxDepartment

Populate Drop Down from Selection on second drop down

So I am trying to populate one dropdown from the selection of another. I have tested the stored proc I am using and, when entering a value, I get the right results. I know there are many questions like this but none seem to fix my issue.
protected void Page_Load(object sender, EventArgs e)
{
DataTable environments = new DataTable();
var connection = ConfigurationManager.ConnectionStrings["Connection"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connection))
{
SqlDataAdapter adapter = new SqlDataAdapter("SELECT Environment FROM Environments", conn);
adapter.Fill(environments);
ddlEnvironment.Items.Insert(0, new ListItem(String.Empty, String.Empty));
ddlEnvironment.SelectedIndex = 0;
ddlEnvironment.DataSource = environments;
ddlEnvironment.DataTextField = "Environment";
ddlEnvironment.DataValueField = "Environment";
ddlEnvironment.DataBind();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter adapter2 = new SqlDataAdapter();
DataTable servers = new DataTable();
cmd = new SqlCommand("sp_EnvironmentSelection", conn);
cmd.Parameters.AddWithValue("#Environment", ddlEnvironment.SelectedValue);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
adapter2.SelectCommand = cmd;
adapter2.Fill(servers);
ddlServer.Items.Insert(0, new ListItem(String.Empty, String.Empty));
ddlServer.SelectedIndex = 0;
ddlServer.DataSource = servers;
ddlServer.DataTextField = "ServerName";
ddlServer.DataValueField = "ServerIP";
ddlServer.DataBind();
}
}
The issue is, I don't get any choices on the second drop down no matter my selection on the first drop down.
Here is the stored proc if needed.
#Environment nvarchar(50)
AS
BEGIN
SET NOCOUNT ON
SELECT Server.ServerName, Server.ServerIP, Environments.Environment
FROM Server
INNER JOIN Environments
ON
Environments.Environment=Server.Environment
WHERE Server.Environment=#Environment
END
If you step through your code as it is executing, you will see that when cmd.Parameters.AddWithValue("#Environment", ddlEnvironment.SelectedValue); is called, ddlEnvironment.SelectedValue will not be set to anything. This is because at the time you're running this code, it's right after ddlEnvironment is being binded to its data. It has no information at that time about what the user selected.
You need to move your binding of the second list into an event handler that handles the ddlEvironment.SelectedIndexChanged event. In there, ddlEnvironment.SelectedValue will be set to what the user selected. And in Page_Load, you do not want to re-bind the first list each time there is a postback, so it needs to be wrapped in an if (!Page.IsPostBack).
See the question here: DropDownList's SelectedIndexChanged event not firing
Your first dropdown list in the asp code needs to look something like this:
<asp:DropDownList ID="ddlEnvironemnt" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlEnvironemnt_SelectedIndexChanged">
</asp:DropDownList>
Your page_load would be like this:
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
return;
}
DataTable environments = new DataTable();
var connection = ConfigurationManager.ConnectionStrings["Connection"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connection))
{
SqlDataAdapter adapter = new SqlDataAdapter("SELECT Environment FROM Environments", conn);
adapter.Fill(environments);
ddlEnvironment.Items.Insert(0, new ListItem(String.Empty, String.Empty));
ddlEnvironment.SelectedIndex = 0;
ddlEnvironment.DataSource = environments;
ddlEnvironment.DataTextField = "Environment";
ddlEnvironment.DataValueField = "Environment";
ddlEnvironment.DataBind();
}
}
And you would have an event handler:
protected void ddlEnvironemnt_SelectedIndexChanged(object sender, EventArgs e)
{
var connection = ConfigurationManager.ConnectionStrings["Connection"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connection))
{
SqlCommand cmd = new SqlCommand();
SqlDataAdapter adapter2 = new SqlDataAdapter();
DataTable servers = new DataTable();
cmd = new SqlCommand("sp_EnvironmentSelection", conn);
cmd.Parameters.AddWithValue("#Environment", ddlEnvironment.SelectedValue);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
adapter2.SelectCommand = cmd;
adapter2.Fill(servers);
ddlServer.Items.Insert(0, new ListItem(String.Empty, String.Empty));
ddlServer.SelectedIndex = 0;
ddlServer.DataSource = servers;
ddlServer.DataTextField = "ServerName";
ddlServer.DataValueField = "ServerIP";
ddlServer.DataBind();
}
}

How to hide items in RadioButtonList after selected

public void Bind_TimeSlots()
{
con.Open();
SqlCommand cmd = new SqlCommand("USP_GETAPPOINTMENTTIME", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("#drid", SqlDbType.VarChar).Value = hdfid.Value;
cmd.Parameters.Add("#APPTDATE", SqlDbType.VarChar).Value = txtdate.Text;
SqlDataReader drAppointmentTimings = cmd.ExecuteReader();
rbtTimeSlots.DataSource = drAppointmentTimings;
rbtTimeSlots.Items.Clear();
rbtTimeSlots.DataTextField = "TimeSlot";
rbtTimeSlots.DataValueField = "id";
rbtTimeSlots.DataBind();
con.Close();
}
protected void btnAppointmentTime_Click(object sender, EventArgs e)
{
Bind_TimeSlots();
}
Here I've RadioButtonList.... and Bind in a Button Click event
Now after selecting the item in RadiButtonList, The item has to hide for next selection
I don't get the reason why you want to do this but :
First Approach
let's say Rating is the ID of the RadioButtonList
Yes, you can hide one by setting its Enabled property to false:
Rating.Items[0].Enabled = false;
Editing based on comment by OP.
To completely get rid of it you'll need to do this:
Rating.Items.RemoveAt(0);
and then when you want it back you'll need to do this:
Rating.Items.Insert(0, "0");
Second Approach
Use CSS i.e
RadioButtonList.Items(1).CssClass.Add("visibility", "hidden")
You can simply do select from text and also you can use FindByValue("val")
public void Bind_TimeSlots()
{
con.Open();
SqlCommand cmd = new SqlCommand("USP_GETAPPOINTMENTTIME", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("#drid", SqlDbType.VarChar).Value = hdfid.Value;
cmd.Parameters.Add("#APPTDATE", SqlDbType.VarChar).Value = txtdate.Text;
SqlDataReader drAppointmentTimings = cmd.ExecuteReader();
rbtTimeSlots.DataSource = drAppointmentTimings;
rbtTimeSlots.Items.Clear();
rbtTimeSlots.DataTextField = "TimeSlot";
rbtTimeSlots.DataValueField = "id";
rbtTimeSlots.DataBind();
con.Close();
}
protected void btnAppointmentTime_Click(object sender, EventArgs e)
{
string selectedval = rbtTimeSlots.SelectedItem.Text; //if by value then SelectedValue.ToString()
Bind_TimeSlots();
if (rbtTimeSlots.Items.FindByText(selectedval) != null) //if by value then rbtTimeSlots.Items.FindByValue(selectedval)()
{
rbtTimeSlots.Items.FindByText(selectedval).Selected = true;
rbtTimeSlots.Items.FindByText(selectedval).Enabled = false;
}
}

3 DropDownLists search function

I'm new to c#, as in.
I'm currently working on a search function in c# using 3 DropDownLists and a submit button. When a user select an item on DropDownList and click submit, it will print the table for the respective selection.
There are 3 DropDownLists:
a province,
city,
specialization.
This will search the available doctors that suits the selection. For example I choose province1 on 1st DropDownList, city1 on the 2nd and a psychologist on 3rd, when the submit button is fired, it will print the available doctors that is in province1, city1 and has a specialization of psychologist.
I already have a code, still figuring it out but, when i click the submit button, nothing is happening. Can someone help me?
Here's what I've done so far:
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(1000);
if (!IsPostBack)
{
string constring = ConfigurationManager.ConnectionStrings["AccreString"].ConnectionString;
SqlConnection conn = new SqlConnection(constring);
DataTable dt = new DataTable("emed_province");
using (conn)
{
conn.Open();
SqlCommand comm = new SqlCommand("SELECT * FROM emed_province ORDER BY PROVINCE_NAME ASC", conn);
SqlDataAdapter adptr = new SqlDataAdapter(comm);
adptr.Fill(dt);
}
ddlProvince.DataSource = dt;
ddlProvince.DataTextField = "PROVINCE_NAME";
ddlProvince.DataValueField = "PROVINCE_CODE";
ddlProvince.DataBind();
ddlProvince.Items.Insert(0, new ListItem("---------------SELECT---------------", "0"));
ddlCity.Items.Insert(0, new ListItem("---------------SELECT---------------", "0"));
ddlSpec.Items.Insert(0, new ListItem("---------------SELECT---------------", "0"));
}
}
protected void ddlProvince_SelectedIndexChanged(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(1000);
string constring = ConfigurationManager.ConnectionStrings["AccreString"].ConnectionString;
SqlConnection conn = new SqlConnection(constring);
DataTable dt = new DataTable("emed_province");
using (conn)
{
conn.Open();
SqlCommand comm = new SqlCommand("SELECT * FROM emed_city WHERE PROVINCE_CODE =#pcode", conn);
comm.Parameters.AddWithValue("#pcode", ddlProvince.SelectedValue);
SqlDataAdapter adptr = new SqlDataAdapter(comm);
adptr.Fill(dt);
SqlParameter param = new SqlParameter();
param.ParameterName = "#pcode";
param.Value = ddlProvince;
comm.Parameters.Add(param);
}
ddlCity.DataSource = dt;
ddlCity.DataTextField = "CITY_NAME";
ddlCity.DataValueField = "CITY_CODE";
ddlCity.DataBind();
ddlCity.Items.Insert(0, new ListItem("---------------SELECT---------------", "0"));
}
protected void ddlCity_SelectedIndexChanged(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(1000);
string constring = ConfigurationManager.ConnectionStrings["AccreString"].ConnectionString;
SqlConnection conn = new SqlConnection(constring);
DataTable dt = new DataTable("emed_city");
using (conn)
{
conn.Open();
SqlCommand comm = new SqlCommand("SELECT * FROM emed_specialization", conn);
comm.Parameters.AddWithValue("#ccode", ddlCity.SelectedValue);
SqlDataAdapter adptr = new SqlDataAdapter(comm);
adptr.Fill(dt);
SqlParameter param = new SqlParameter();
param.ParameterName = "#ccode";
param.Value = ddlCity;
comm.Parameters.Add(param);
}
ddlSpec.DataSource = dt;
ddlSpec.DataTextField = "SPEC_NAME";
ddlSpec.DataValueField = "SPEC_CODE";
ddlSpec.DataBind();
ddlSpec.Items.Insert(0, new ListItem("---------------SELECT---------------", "0"));
}
protected void btnSub_Click(object sender, EventArgs e)
{
string constring = ConfigurationManager.ConnectionStrings["AccreString"].ConnectionString;
SqlConnection conn = new SqlConnection(constring);
DataTable dt = new DataTable("emed_doctors");
using (conn)
{
conn.Open();
SqlCommand comm = new SqlCommand("SELECT DOCTOR_NAME FROM emed_doctors where Province = '" + ddlProvince.SelectedItem.ToString() + "'", conn);
SqlDataAdapter adptr = new SqlDataAdapter(comm);
adptr.Fill(dt);
}
}
}
Make change in this line of code which is in submit button click function
Correct code:
SqlCommand comm = new SqlCommand("SELECT DOCTOR_NAME FROM emed_doctors where province = '" + ddlProvince.SelectedItem.ToString() + "'", conn);
because as you see your code query is incorrent have look to your code which is incorrect
Wrong code:
SqlCommand comm = new SqlCommand("SELECT DOCTOR_NAME FROM emed_doctors where (" + ddlProvince.SelectedItem.ToString() + " ", conn);
Edit:
if you want to display record that you got in DataTable you either need loop through the records or you need to use GridView for that...i think you miss that thing
in above one after where clause you miss the name of the filed you need to made filter on... i have written update code by modifying that condition.
See MSDN for GridView.
You said that after clicking submit, nothing happend. But in btnSub_Click I didn't see anything that displaying the result or changing anything on the page. You should bind dt to some control like a gridview etc.

Categories

Resources