我有一個GridView,有一些列。如果在我的數據庫中存在一個值,我的gridview中的單元格必須更新自己的值。如何在我的GridView中編輯單元格(如果某些要求爲真)
例如:
1 2
1 - Lucas Delete
2 - Drake Delete
3 - Jimmy Update/Delete
如果吉米在我的數據庫存在,那麼我必須把「更新/刪除」在我的第二列,但如果點擊該「更新」標籤,我稱之爲JavaScript的。我怎樣才能做到這一點 ?它可以通過Sql完成?
我的後臺代碼:
protected void carregaGrid()
{
Utilidade.QuebraToken tk = new Utilidade.QuebraToken();
string Credenciada = tk.CarregaToken(1, Request.Cookies["token"].Value);
string Proposta = string.Empty;
string select = string.Empty;
select = "SELECT San_Proposta.Proposta_Id, San_Proposta.DataHora, San_Proposta.ValorProposta, San_Proposta.Comentario, "
+ "San_Usuario.NomeCompleto, San_Credenciada.Apelido, San_StatusProposta.Descricao, "
+ "(SELECT COUNT(*) "
+ "FROM San_PropostaConversa "
+ "WHERE San_PropostaConversa.Proposta_Id = San_Proposta.Proposta_Id "
+ "AND San_PropostaConversa.Credenciada_Id = San_Proposta.Credenciada_Id) as Numero "
+ "FROM San_Proposta "
+ "JOIN San_Credenciada "
+ "ON San_Proposta.Credenciada_Id = San_Credenciada.Credenciada_Id "
+ "JOIN San_StatusProposta "
+ "ON San_Proposta.StatusProposta_Id = San_StatusProposta.StatusProposta_Id "
+ "JOIN San_Usuario "
+ "ON San_Proposta.Usuario_Id = San_Usuario.Usuario_Id ";
if (Request.QueryString["Imovel_Id"].ToString() != string.Empty)
{
string imovel = Request.QueryString["Imovel_Id"].ToString();
select += "WHERE San_Proposta.Imovel_Id = " + imovel + " "
+ "AND San_Proposta.Credenciada_Id = " + Credenciada + " "
+ "AND San_Proposta.StatusProposta_Id IN (1,2) ";
}
}
select += "ORDER BY San_Proposta.DataHora DESC, Apelido ";
neticonn.Conexao c = new neticonn.Conexao();
dsGrid.ConnectionString = c.Con;
dsGrid.SelectCommand = select;
}
請顯示您的代碼 – gideon 2012-02-23 14:56:45
偏離主題,您可能希望在SQL選擇字符串中使用@ -quoted逐字字符串文本而不是所有這些+運算符。 – 2012-02-23 15:22:44