Should be an easy one.

R

R-D-C

Hi,

I am looking for some help because I am gradually running out of hair!

I have a database from which I retreve a list of items. In the Page_Load of
a web user control I dynamically add LinkButtons with their text properties
set to the values from the database. I point their click events all to one
procedure, called l_click.

In this procedure I want to disable the clicked LinkButton whilst enabling
all the others, effectively highlighting by disabling the selected item from
my list. This will allow my application to group information according to
these links as group headings. I also raise an event so the page with the
control on can see the change. The event stuff works fine.

The bit that is driving me mad is the disabling. I loop through all the
LinkButtons. If I find the one I am looking for I disable it and raise my
event. If the one I am looking at is not the right one, I enable it - the
idea being that I will end up with just one item disabled. This does not
work. Only the last item will enable / disable. When clicking the others,
the event is raised but the control stays enabled and the last control
remains disabled at all times once it has been clicked.

Can anyone help?

the code for l_Click is as follows:

// Handle the clicking of a link

private void l_Click(object sender, EventArgs e)

{

// Get reference to clicked link button

LinkButton l = (LinkButton)sender;

// Identify the ID of the link clicked

foreach (DataRow dr in mdsLinks.Tables[0].Rows) // The dataset with the
full list of links in

{

string sCompare = "[" + dr["DisplayName"].ToString() + "]";

if(l.Text.Trim() == sCompare)

{

miLinkID = Convert.ToInt32(dr["LinkID"]);

l.Font.Bold=true;

l.Text += " ";

}

else

{

l.Font.Bold=false;

l.Text = l.Text.Trim();

}

}

// Raise event to indicate selection change

if (LinkSelected!=null)

LinkSelected(miDatabaseID);

}
 
R

R-D-C

Duh!

Sometimes I wish I could delete my messages from newsgroups.

My logic is stupid.
 

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

Top