Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to import data from database in a dataview but the hyperlink delete,edit and ceate does not work!!!!
Posted
Comments
Garth J Lancaster 8-Jan-13 4:45am    
Have you written any code ? how about providing the smallest code block that displays the errant behaviour, rather than a general 'x, y & z does not work'. What tests have you done, how do you reproduce the error for example ? Only you can supply this information - we cant read your mind or see what's running on your machine !

1 solution

I just giving you my solution...I hope it will help you..

In design page in grid view add

<asp:commandfield showeditbutton="True" headertext="Update" xmlns:asp="#unknown">


Then in .cs page

C#
protected void gvDeleteCh_RowEditing(object sender, GridViewEditEventArgs e)
    {
        gvDeleteCh.EditIndex = e.NewEditIndex; 
        strinfo = "Select * from tblname"; // your query to data which u want to edit.
        LoadGrid1(strinfo);
    }


C#
protected void gvDeleteCh_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
       // Page.RegisterStartupScript("MY","function msgAlert()");
        try
        {
               try
                {
                    Ocon = new OracleConnection(OracleconnectionString);
                    Ocon.Open();
                    string Name = (((TextBox)gvDeleteCh.Rows[e.RowIndex].Cells[0].Controls[0]).Text.Trim());
                    string UID = (((TextBox)gvDeleteCh.Rows[e.RowIndex].Cells[1].Controls[0]).Text.Trim());
                    string ID = (((TextBox)gvDeleteCh.Rows[e.RowIndex].Cells[2].Controls[0]).Text.Trim());
                    string ISACTIVE = (((TextBox)gvDeleteCh.Rows[e.RowIndex].Cells[3].Controls[0]).Text.Trim());
                    string strSQuery = "update MASTER_TEST set Name='" + Name + "',"
     + "UID='"+UID+"',ID='" + ID + "',ISACTIVE='" + ISACTIVE + "' where UID='"+ UID +"'";
  //   + "select Name,UID,ID,ISACTIVE from MASTER_TEST";
                    Ocmd = new OracleCommand(strSQuery, Ocon);
                    Ocmd.ExecuteNonQuery();
                    lblMsg.Text = "Successfully Updated";
                    TestLog.WriteLog("Updated Successfully " + DateTime.Now);
                    Ocon.Close();
                 }
                catch(Exception ex)
                {
                    lblMsg.Text = ex.Message;
                    TestLog.WriteLog("Error occured while updating the channel " + DateTime.Now);
                
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
        gvDeleteCh.EditIndex = -1;
    }
    protected void gvDeleteCh_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        gvDeleteCh.EditIndex = -1;
        LoadChannels();
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900