datagrid problem

Results 1 to 2 of 2

Thread: datagrid problem

  1. #1
    Join Date
    Dec 1969

    Default datagrid problem

    Hi,<BR><BR>I have 2 datagrids on 1 page and the second one is filled with only 1 record. I&#039;m trying to update the second one but I can&#039;t get it to update my data. The error I&#039;m getting is input string was not in a correct format.... I&#039;m using an access database, the ID column is an autonumber long integer and the @ID parameter is declared as Integer. What&#039;s wrong ?<BR><BR>Anyway here&#039;s my code : (you can answer in VB if you like, i can read it).<BR><BR>private void bindDetails()<BR> {<BR> dsUser = (DataSet)Cache["User"];<BR> dgUser.DataBind();<BR> }<BR><BR>private void updateUser(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)<BR> {<BR> try<BR> {<BR> lblMsg.Text="";<BR> cmdUpdUser.Parameters["@ID"].Value = Convert.ToInt64(e.Item.FindControl("lblID").ToStri ng());<BR> cmdUpdUser.Parameters["@Name"].Value = e.Item.FindControl("tbName").ToString();<BR> cmdUpdUser.Parameters["@Adres"].Value = e.Item.FindControl("tbAddress").ToString();<BR> cmdUpdUser.Parameters["@post"].Value = e.Item.FindControl("tbPost").ToString();<BR> cmdUpdUser.Parameters["@gem"].Value = e.Item.FindControl("tbCity").ToString();<BR> cmdUpdUser.Parameters["@bank"].Value = e.Item.FindControl("tbBank").ToString();<BR> cmdUpdUser.Parameters["@vat"].Value = e.Item.FindControl("tbVat").ToString();<BR> cmdUpdUser.Parameters["@tel"].Value = e.Item.FindControl("tbTel").ToString();<BR> cmdUpdUser.Parameters["@fax"].Value = e.Item.FindControl("tbFax").ToString();<BR> cmdUpdUser.Parameters["@email"].Value = e.Item.FindControl("tbEmail").ToString();<BR> cmdUpdUser.Parameters["@web"].Value = e.Item.FindControl("tbWeb").ToString();<BR> cmdUpdUser.Parameters["@rema"].Value = e.Item.FindControl("tbRem").ToString();<BR> cmdUpdUser.Parameters["@mobi"].Value = e.Item.FindControl("tbMob").ToString();<BR> kkConn1.Open();<BR> cmdUpdUser.ExecuteNonQuery();<BR> daUser.Fill(dsUser);<BR> Cache["User"] = dsUser;<BR> dgUser.EditItemIndex = -1;<BR> bindDetails();<BR> kkConn1.Close();<BR> }<BR> catch (Exception ex)<BR> {<BR> lblMsg.Text=ex.Message;<BR> }<BR> } <BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default String needs to be int (IF that is the problem fie

    cmdUpdUser.Parameters["@ID"].Value = cint((e.Item.FindControl("lblID"));<BR><BR>It looks like you were converting it to int64, then back to a string. This may work as well:<BR><BR> cmdUpdUser.Parameters["@ID"].Value = Convert.ToInt64(e.Item.FindControl("lblID"));

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts