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)
   {
    if(!isRole("Manager"))
    {
     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
๐Ÿ“ asp.net.object-datasource
๐Ÿ“ƒ 16182 articles.
โญ 0 followers.

๐Ÿ’ฌ 3 Replies
๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ 2782 Views

The Templete column:

<asp:TemplateColumn HeaderText="้€š่ฟ‡">
	<HeaderStyle Wrap="False" Width="5%"></HeaderStyle>
	<ItemStyle Wrap="False" HorizontalAlign="Center"></ItemStyle>
	<ItemTemplate>
		<asp:LinkButton id=lbPassed runat="server" Text='
0
iamybj
4/11/2007 1:27:03 AM

Hi,

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.


Sincerely,
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

Hi,

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. 

Hamlin

------------------------------------------------------------------------------------

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

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