我已經在gridview中填充數據。gridview我有一個鏈接按鈕,當點擊它會使一個面板visible.Now我想保留id在會話中選中的行並在面板中使用它。我也知道如何找出gridview的id,但是當選定該特定行的鏈接按鈕時,我無法生成gridview事件。選擇GridView中的鏈接按鈕的行的編號
private void Bindgrid()
{
if (Session["CartId"] != null)
{
DataTable dt = new DataTable();
int introws = 0;
//string mandir_id = Request.QueryString["id"];
string cmdstr = "select p.id,p.name,p.photo_id,p.price,m.name from puja p,mandir m,shoppingcart s where s.session_id='" + Session["CartId"] + "' and p.with_mandir=m.id and p.id=s.with_puja";
//sQLcONN.Open();
MySqlCommand cmd = new MySqlCommand(cmdstr, sQLcONN);
MySqlDataAdapter adp = new MySqlDataAdapter(cmd);
adp.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
sQLcONN.Close();
}
else { }
}
protected void Linkedit_click(object sender, EventArgs e)
{
pnl1.Visible = true;
}
而這是我真正需要獲取該ID的面板中的按鈕事件。
protected void submit_Click(object sender, EventArgs e)
{
string price = Session["price"].ToString();
WebClient web = new WebClient();
string url = string.Format("http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s={0}{1}=X", ddlFrom.SelectedValue.ToUpper(), ddlTo.SelectedValue.ToUpper());
string response = web.DownloadString(url);
string[] values = Regex.Split(response, ",");
decimal rate = System.Convert.ToDecimal(values[1]);
decimal amount = System.Convert.ToDecimal(price);
rate = rate * amount;
//string result = System.Convert.ToString(rate);
//result = rate;
//rate = System.Convert.ToDecimal(lblResult.Text);
lblResult.Text = rate.ToString();
}
請幫我解決這個....
你可以使用這個rowcommand事件, –