TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vikas vanvi
NA
17
2.6k
Not able to call method
Dec 7 2013 8:48 AM
when i debug, from
gridviewbind();
deleteCart(pic);
it stops,and it is not entering into
public void deleteCart(string orderID)
, what could be a problem?
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
gridviewbind();
}
}
public void gridviewbind()
{
SqlConnection con = new SqlConnection("constring1");
string str = "select * from Products INNER JOIN orders on Products.picID=orders.productID";
SqlCommand cmd = new SqlCommand(str, con);
con.Open();
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("picID", typeof(int)));
dt.Columns.Add(new DataColumn("title", typeof(string)));
dt.Columns.Add(new DataColumn("price", typeof(int)));
dt.Columns.Add(new DataColumn("dateAdded", typeof(DateTime)));
dt.Columns.Add(new DataColumn("picURL", typeof(string)));
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
DataRow dr = dt.NewRow();
dr["picID"] = Convert.ToInt32(reader["picID"]);
dr["title"] = reader["title"];
dr["price"] = Convert.ToInt32(reader["price"]);
dr["dateAdded"] = reader["dateAdded"];
dr["picURL"] = ResolveUrl("~/images/" + reader["picURL"]);
dt.Rows.Add(dr);
}
reader.Close();
con.Close();
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void Gridview1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "removeRow")
{
string pic = Convert.ToString(e.CommandArgument);
// GridViewRow row = GridView1.Rows[pic];
// deleteCart(row.Cells[1].Text.ToString());
gridviewbind();
deleteCart(pic);
}
}
public void deleteCart(string orderID)
{
using (SqlConnection con = new SqlConnection("constring1"))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "delete from orders where orderID=@orderID";
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@orderID", orderID);
con.Open();
var temp = cmd.ExecuteNonQuery();
con.Close();
}
}
}
Reply
Answers (
1
)
Converting to byte from picturebox
In Form1, how to get a value from Main()?