gridview control not selecting the right row

1 posts, 0 answers
  1. akpaga akpaga
    akpaga akpaga avatar
    24 posts
    Member since:
    Dec 2009

    Posted 31 Dec 2009 Link to this post

     the problem is that when i clcik the link in the delete coloumn of gridview (which is a delete command)

    Actually i have an update query changing the status field  for the delete command query so the row is not deleted but just the status field is changes when delete button is clicked.
    it makes isinEditMode =false for the row below the one for which i clicked  instead of the row for which i clicked. Here is the code

    for the gridview coloumn customer_notes

    <asp:TemplateField HeaderText="Customer_Notes" SortExpression="Customer_Notes">

    <asp:Label ID="labelco" Visible='<%# !(bool) IsInEditMode %>' runat="server" Text='<%# Bind("Customer_Notes") %>'></asp:Label>
    <asp:TextBox ID="Customer_Notes" Visible='<%# IsInEditMode %>' TextMode="MultiLine" runat="server" Text='<%# Bind("Customer_Notes") %>'></asp:TextBox>

    When the isineditmode = true it should be showing the textbox which then makes it editable....

    everything works but  when when i click on the absent link it chanes to " undo absent"   then iseditmode should be false for that  row

    but the row below it is getting the value iseditmode =false.  This the only thing stopping my project.....What is the reason

    code for the rowdataboundevent


    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

    if (e.Row.RowType == DataControlRowType.DataRow ||e.Row.RowType == DataControlRowType.EmptyDataRow)

    LinkButton lnk = (LinkButton)e.Row.FindControl("LinkButton1");

    DataRowView rowView = (DataRowView)e.Row.DataItem;
    //Setup a boolean equal to the bitvalud of your DB field
    int test = Convert.ToInt32(rowView["Status"]);

    if (test == 0)

    lnk.Text = "customer";
    lnk.Font.Bold = true;
    lnk.ForeColor = System.Drawing.Color.DarkOliveGreen ;
    lnk.CommandName = "Delete";

    isEditMode = true;

    else if (test == 1)
    lnk.Text = "NOT Customer";
    lnk.Font.Bold = true;
    lnk.ForeColor = System.Drawing.Color.DeepSkyBlue ;
    lnk.CommandName = "Delete";

    isEditMode = false;


    //set datasource of GridView


Back to Top