changing name on Select button

  • Thread starter Thread starter JohnE
  • Start date Start date
J

JohnE

I have a gridview that has a left column that displays 'Select' for selecting
the row. I have the followng code that will select/deselect the row when the
'Select' is used. What is being asked for is to have 'Select' change to
'Unselect' (or Deselect) when the row is highlighted. How would that be
place in the code that is currently being used?

protected void GridView1_SelectedIndexChanging(object sender,
GridViewSelectEventArgs e)
{
if (GridView1.SelectedIndex == e.NewSelectedIndex)
{
e.Cancel = true;
GridView1.SelectedIndex = -1;
}
}

Thanks for the assistance.
John
 
I have a gridview that has a left column that displays 'Select' for selecting
the row.  I have the followng code that will select/deselect the row when the
'Select' is used.  What is being asked for is to have 'Select' change to
'Unselect' (or Deselect) when the row is highlighted.  How would that be
place in the code that is currently being used?

    protected void GridView1_SelectedIndexChanging(object sender,
GridViewSelectEventArgs e)
    {
        if (GridView1.SelectedIndex == e.NewSelectedIndex)
        {
            e.Cancel = true;
            GridView1.SelectedIndex = -1;
        }
    }

Thanks for the assistance.
John

GridView doesn't support multiple selection. Either one row is
selected or none are selected. Your code already represents the most
that can be achieved.
 
Stan said:
GridView doesn't support multiple selection. Either one row is
selected or none are selected. Your code already represents the most
that can be achieved.

I didn't ask for a multiple select. When someone selects a row using the
Select command on the left side of the gridview, the text name should change
to 'Unselect' so the user knows how to un-select the row. The code here does
the select / unselect of a row but does not change the text name (or
commandname). That is what I am looking for.
 
I've only used ListView and I was able to accomplish something simular with
the FindControl Property

Not sure, but I'm wondering if something like this might point you in the
right direction in discovering your solution?

protected void GridView1_SelectedIndexChanging(object sender,
GridViewSelectEventArgs e)
{
if (GridView1.SelectedIndex == e.NewSelectedIndex)
{
e.Cancel = true;
GridView1.SelectedIndex = -1;

Label l;
l = (Button) e.Item.FindControl("SelectButton");

if(!(l == null) ){
l.Text="Selected";}
}
}
 
Back
Top