changing name on Select button

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
 
S

Stan

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.
 
J

JohnE

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.
 
G

Giles Evans

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";}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top