Help! I cannot access the DataGrid's ItemTemplate's LinkButton's Text Atrribute 's Value!!!!!!!!!!!

I write a datagrid's ItemDataBound method as follows:

  private void dgTable_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
   if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     LinkButton tmp = (LinkButton)e.Item.FindControl("lbPassed");
     if(tmp.Text == "Passed")
      ((LinkButton)e.Item.FindControl("lbEdit")).Enabled = false;
      ((LinkButton)e.Item.FindControl("lbDelete")).Enabled = false;
     tmp.Enabled = false;

The Templete Column:

   ' runat="server">' runat="server">' runat="server">' runat="server">' runat="server">' runat="server">

I want that if the user is not a manager and a LinkButton's value is "Passed", then hidden 2 columns, so the user cannot edit or delete it.

Last night,the code run good, but this moring, I found (tmp.Text == "Passed") aways return false, beacause tmp.Text aways is "" !!!

I use vs2003, I found some bugs in it, although i installed sp1;

0 iamybj 4/11/2007 1:05:40 AM

The Templete column:

0 iamybj 4/11/2007 1:27:03 AM


I suggest you check if there is a typo error in your code or on the ASPX page to see if it displays Passed exactly. Is there a space there?

You can also use VS.NET to debug it. Attach it to the process and set a breakpoint in this line of code. In the watch window, you can see what is actually displayed for the linkButton text.

Kevin Yu
Microsoft Online Community Support

Please remember to click €œMark as Answer€ on the post that helps you, and to click €œMark as Not Answer€ if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
0 Kevin 4/16/2007 6:56:25 AM


Use debugger. Check for the value of 'lblPassed'. Make sure that the databinding code is still there for 'lblPassed'. You can verify it in template edit or in code behind file. Make sure that you are passing the correct label for checking.

Hope this could help. 



Don't forget to "Mark As Answer" if this post helps you.

0 hamlin 4/16/2007 7:15:44 AM

(Thread closed)