Click here to Skip to main content
15,925,505 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Server Error in '/' Application. Pin
zeeShan anSari18-Mar-08 21:08
zeeShan anSari18-Mar-08 21:08 
GeneralRe: Server Error in '/' Application. Pin
N a v a n e e t h18-Mar-08 21:14
N a v a n e e t h18-Mar-08 21:14 
GeneralRe: Server Error in '/' Application. Pin
Laddie18-Mar-08 22:35
Laddie18-Mar-08 22:35 
GeneralDisplay data in datalist at runtime Pin
raushan_918-Mar-08 20:17
raushan_918-Mar-08 20:17 
General[Message Deleted] Pin
yogeshpan18-Mar-08 19:45
yogeshpan18-Mar-08 19:45 
GeneralRe: Email Sending in asp.net 2.0 using C# Pin
Christian Graus18-Mar-08 20:31
protectorChristian Graus18-Mar-08 20:31 
GeneralCommand Prompt Calling and Parsing Pin
Michael10118-Mar-08 18:12
Michael10118-Mar-08 18:12 
GeneralRe: Command Prompt Calling and Parsing Pin
N a v a n e e t h18-Mar-08 20:26
N a v a n e e t h18-Mar-08 20:26 
QuestionINSERT IMAGES TO SQL SERVER TABLE USING C# CODING Pin
Phivos Stylianides18-Mar-08 11:54
Phivos Stylianides18-Mar-08 11:54 
GeneralRe: INSERT IMAGES TO SQL SERVER TABLE USING C# CODING Pin
pmarfleet18-Mar-08 12:17
pmarfleet18-Mar-08 12:17 
QuestionRe: INSERT IMAGES TO SQL SERVER TABLE USING C# CODING Pin
Phivos Stylianides18-Mar-08 12:26
Phivos Stylianides18-Mar-08 12:26 
GeneralRe: INSERT IMAGES TO SQL SERVER TABLE USING C# CODING Pin
Not Active18-Mar-08 12:48
mentorNot Active18-Mar-08 12:48 
QuestionRe: INSERT IMAGES TO SQL SERVER TABLE USING C# CODING Pin
Phivos Stylianides18-Mar-08 13:06
Phivos Stylianides18-Mar-08 13:06 
GeneralRe: INSERT IMAGES TO SQL SERVER TABLE USING C# CODING Pin
Not Active18-Mar-08 14:19
mentorNot Active18-Mar-08 14:19 
QuestionRe: INSERT IMAGES TO SQL SERVER TABLE USING C# CODING Pin
Phivos Stylianides18-Mar-08 15:06
Phivos Stylianides18-Mar-08 15:06 
GeneralRe: INSERT IMAGES TO SQL SERVER TABLE USING C# CODING Pin
Not Active18-Mar-08 15:53
mentorNot Active18-Mar-08 15:53 
General"Unable to cast object of type " in Gridview control when click on add button [modified] Pin
amistry_petlad18-Mar-08 9:51
amistry_petlad18-Mar-08 9:51 
GeneralRe: "Unable to cast object of type " in Gridview control when click on add button Pin
pmarfleet18-Mar-08 11:19
pmarfleet18-Mar-08 11:19 
GeneralRe: "Unable to cast object of type " in Gridview control when click on add button Pin
Not Active18-Mar-08 11:35
mentorNot Active18-Mar-08 11:35 
QuestionRe: "Unable to cast object of type " in Gridview control when click on add button Pin
amistry_petlad18-Mar-08 13:32
amistry_petlad18-Mar-08 13:32 
GeneralRe: "Unable to cast object of type " in Gridview control when click on add button Pin
Not Active18-Mar-08 14:20
mentorNot Active18-Mar-08 14:20 
GeneralRe: "Unable to cast object of type " in Gridview control when click on add button Pin
amistry_petlad19-Mar-08 5:04
amistry_petlad19-Mar-08 5:04 
GeneralRe: "Unable to cast object of type " in Gridview control when click on add button Pin
Not Active19-Mar-08 5:57
mentorNot Active19-Mar-08 5:57 
GeneralRe: "Unable to cast object of type " in Gridview control when click on add button Pin
amistry_petlad20-Mar-08 3:36
amistry_petlad20-Mar-08 3:36 
Ya solve the problem ,But I have a question when I have used command button in the gridview now when i
click the "Insert" for new record the linkbutton every time use the "update" action so rather then inserting new record.
what should I do?
I had debug the application and explicitly put the value then it takes but when i use routine its default takes "Update" every time.
Please look at little code for understanding.

when click on addbutton

 protected void btnAdd_Click(object sender, EventArgs e)<br />
    {<br />
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MYConnectionString"].ConnectionString);<br />
        SqlDataAdapter da = new SqlDataAdapter("SELECT subcat_id,subcatename,description,Pid  FROM Subcatagory", con);<br />
        DataTable dt = new DataTable();<br />
        da.Fill(dt);<br />
<br />
        // Here we'll add a blank row to the returned DataTable<br />
        DataRow dr = dt.NewRow();<br />
        dt.Rows.InsertAt(dr, 0);<br />
        //Creating the first row of GridView to be Editable<br />
        GridView1.EditIndex = 0;<br />
        GridView1.DataSource = dt;<br />
        GridView1.DataBind();<br />
        <br />
        //Changing the Text for Inserting a New Record<br />
<br />
        //dt.Reset();<br />
         //here the lick button shown "insert"<br />
        ((LinkButton)GridView1.Rows[0].Cells[5].Controls[0]).Text = "Insert";<br />
        Session["operation"] = "Insert"; <br />
<br />
    }<br />
<br />
When control leaves the scope it automatic use "Update"<br />


For row updating

<br />
<br />
  protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)<br />
    {<br />
<br />
           <big>// The following link button every time shown me update value</big><br />
<br />
        if (((LinkButton)GridView1.Rows[0].Cells[5].Controls[0]).Text == "Insert" || Session["operation"] == "Insert")<br />
        {<br />
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MYConnectionString"].ConnectionString);<br />
            SqlCommand cmd = new SqlCommand();<br />
            cmd.CommandText = "INSERT INTO Subcatagory(subcatename,description,Pid) VALUES(@subcatename,@description,@Pid)";<br />
            //cmd.CommandText = "INSERT INTO Subcatagory(subcatename,description,Pid) VALUES('llll','kkkkk',1)";<br />
            cmd.Parameters.Add("@subcatename", SqlDbType.VarChar).Value = ((TextBox)GridView1.Rows[0].Cells[2].Controls[0]).Text;<br />
            cmd.Parameters.Add("@description", SqlDbType.VarChar).Value = ((TextBox)GridView1.Rows[0].Cells[4].Controls[0]).Text;<br />
            cmd.Parameters.Add("@Pid", SqlDbType.Int).Value = Int32.Parse(Request.QueryString["Pid"]);        <br />
            cmd.Connection = con;<br />
            con.Open();<br />
            cmd.ExecuteNonQuery();<br />
            con.Close();<br />
<br />
        }<br />
        else<br />
        {<br />
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MYConnectionString"].ConnectionString);<br />
            SqlCommand cmd = new SqlCommand();<br />
            cmd.CommandText = "UPDATE Subcatagory SET subcatename=@subcatename,description=@description WHERE subcat_id=@subcat_id";<br />
            cmd.Parameters.Add("@subcatename", SqlDbType.VarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;<br />
            cmd.Parameters.Add("@description", SqlDbType.VarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text;<br />
            cmd.Parameters.Add("@subcat_id", SqlDbType.Int).Value = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[1].Text);<br />
            cmd.Connection = con;<br />
            con.Open();<br />
            cmd.ExecuteNonQuery();<br />
            con.Close();<br />
}<br />
<br />
<br />
        GridView1.EditIndex = -1;<br />
        BindData();<br />
    }<br />
<br />
<br />
<br />

GeneralFormView Not Inserting Pin
Brady Kelly18-Mar-08 7:50
Brady Kelly18-Mar-08 7:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.