This is a migrated thread and some comments may be shown as answers.

gridview control not selecting the right row

0 Answers 36 Views
Getting started with ASP.NET
This is a migrated thread and some comments may be shown as answers.
akpaga akpaga
Top achievements
Rank 1
akpaga akpaga asked on 31 Dec 2009, 05:54 PM
 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">

<ItemTemplate>
<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>
</ItemTemplate>
</asp:TemplateField>

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





}





}
 

No answers yet. Maybe you can help?

Tags
Getting started with ASP.NET
Asked by
akpaga akpaga
Top achievements
Rank 1
Share this question
or