Click here to Skip to main content
15,914,481 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionModal dialog opacity Pin
devvvy9-Dec-08 16:13
devvvy9-Dec-08 16:13 
QuestionHttp Modules Pin
CrimeanTurtle20089-Dec-08 13:49
CrimeanTurtle20089-Dec-08 13:49 
AnswerRe: Http Modules Pin
N a v a n e e t h9-Dec-08 17:38
N a v a n e e t h9-Dec-08 17:38 
GeneralRe: Http Modules Pin
CrimeanTurtle200812-Dec-08 23:20
CrimeanTurtle200812-Dec-08 23:20 
QuestionPlease HELP urgent prob with datepicker control on my form! [modified] Pin
dee cronin9-Dec-08 13:37
dee cronin9-Dec-08 13:37 
AnswerRe: Please HELP urgent prob with datepicker control on my form! Pin
dee cronin9-Dec-08 16:49
dee cronin9-Dec-08 16:49 
GeneralRe: Please HELP urgent prob with datepicker control on my form! Pin
N a v a n e e t h9-Dec-08 17:40
N a v a n e e t h9-Dec-08 17:40 
QuestionTrying to access a Repeater's HeaderTemplate controls from event fired in an ItemTemplate control Pin
Cyrilix9-Dec-08 10:51
Cyrilix9-Dec-08 10:51 
I've got an ASP .NET webpage with the following structure:
<asp:DataGrid ID="aGrid">
  <Columns>
    <asp:TemplateColumn>
      <ItemTemplate>
        <asp:Repeater ID="aRepeater">
          <HeaderTemplate>
            <asp:Label ID="aLabel" Text='<%# DataBinder.Eval(Container.DataItem, "SomeColumn") %>'></asp:Label>
          </HeaderTemplate>
          <ItemTemplate>
            <asp:TextBox ID="aTextBox" AutoPostBack="true" OnTextChanged="SomeEvent"></asp:TextBox>
          </ItemTemplate>
        </asp:Repeater>
      </ItemTemplate>
    </asp:TemplateColumn>
  </Columns>
</asp:DataGrid>


The problem I'm having is that I would like to access the data that is stored in the label aLabel in the OnTextChanged event. What I'm doing to achieve this purpose is:

void SomeEvent(object sender, EventArgs e)
{
    //Bind aRepeater to a certain data source in the ItemDataBound event of aGrid

    //Get reference to aRepeater
    //Parent gets you the RepeaterItem
    //Parent.Parent gets you the Repeater
    Repeater r = (sender as TextBox).Parent.Parent;
    
    //Assert that r.DataSource != null
}


My assertion, however, fails, and even if I get aLabel.Text, it ends up being an empty string, since r.DataSource is null (despite the fact that in the ItemDataBound event of aGrid, I already bound the repeater to a data source). After some debugging, I noticed that Repeater r is not the same repeater as the one that I bound in the ItemDataBound event of aGrid, but how could that be? In the ItemDataBound event of aGrid, I do the following...

<br />
//e is DataGridItemEventArgs object in ItemDataBound event<br />
e.Item.FindControl("aRepeater") as Repeater;<br />


...which I assume should be equivalent to...

(sender as TextBox).Parent.Parent;

Sorry for the long post.
Questionemail script Pin
bjh299-Dec-08 9:13
bjh299-Dec-08 9:13 
AnswerRe: email script Pin
Christian Graus9-Dec-08 9:57
protectorChristian Graus9-Dec-08 9:57 
GeneralRe: email script Pin
bjh299-Dec-08 10:21
bjh299-Dec-08 10:21 
GeneralRe: email script Pin
Christian Graus9-Dec-08 11:16
protectorChristian Graus9-Dec-08 11:16 
GeneralRe: email script Pin
bjh299-Dec-08 11:57
bjh299-Dec-08 11:57 
GeneralRe: email script Pin
Christian Graus9-Dec-08 13:29
protectorChristian Graus9-Dec-08 13:29 
GeneralRe: email script Pin
bjh299-Dec-08 14:22
bjh299-Dec-08 14:22 
AnswerRe: email script Pin
N a v a n e e t h9-Dec-08 17:56
N a v a n e e t h9-Dec-08 17:56 
GeneralRe: email script Pin
bjh2910-Dec-08 3:17
bjh2910-Dec-08 3:17 
QuestionMaster Page - Beginner Question... Pin
AndyInUK9-Dec-08 7:55
AndyInUK9-Dec-08 7:55 
AnswerRe: Master Page - Beginner Question... Pin
Christian Graus9-Dec-08 9:58
protectorChristian Graus9-Dec-08 9:58 
QuestionProblem with German special character Pin
Kermit2119-Dec-08 6:18
Kermit2119-Dec-08 6:18 
AnswerRe: Problem with German special character Pin
led mike9-Dec-08 8:11
led mike9-Dec-08 8:11 
Questionneed to exit virtual directory Pin
Hanzaplast9-Dec-08 5:18
Hanzaplast9-Dec-08 5:18 
AnswerRe: need to exit virtual directory Pin
Christian Graus9-Dec-08 10:00
protectorChristian Graus9-Dec-08 10:00 
Questionlive web conferencing Pin
meghamaharshi9-Dec-08 2:11
meghamaharshi9-Dec-08 2:11 
AnswerRe: live web conferencing Pin
Abhijit Jana9-Dec-08 3:55
professionalAbhijit Jana9-Dec-08 3:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.