Click here to Skip to main content
15,897,891 members
Home / Discussions / C#
   

C#

 
GeneralRe: Why does this not change my string? Pin
stephen.darling15-Aug-11 12:14
stephen.darling15-Aug-11 12:14 
GeneralRe: Why does this not change my string? Pin
fcronin16-Aug-11 2:39
fcronin16-Aug-11 2:39 
GeneralRe: Why does this not change my string? Pin
stephen.darling16-Aug-11 7:27
stephen.darling16-Aug-11 7:27 
AnswerRe: Why does this not change my string? Pin
PIEBALDconsult15-Aug-11 15:30
mvePIEBALDconsult15-Aug-11 15:30 
AnswerRe: Why does this not change my string? [modified] Pin
Shameel15-Aug-11 21:33
professionalShameel15-Aug-11 21:33 
GeneralRe: Why does this not change my string? Pin
Matt Meyer16-Aug-11 5:50
Matt Meyer16-Aug-11 5:50 
GeneralRe: Why does this not change my string? Pin
Shameel16-Aug-11 8:45
professionalShameel16-Aug-11 8:45 
QuestionFind asp.net listview control in Item Template Pin
akosidandan15-Aug-11 6:05
akosidandan15-Aug-11 6:05 
Hello Experts,


I would like to ask how will I find the listview control or use the correct event. My goal is that I want to check the listview control text value inside of listview item template after it load the data, then I have a condition to trigger some code depends on what my control text result.

Here is my Code I am not sure why it does not work and it always give me
Object reference not set to an instance of an object.


The aspx page Code
XML
<ItemTemplate>
               <tr style="">
                   <td>
                       <asp:Label ID="AnnouncementMessageLabel" runat="server"
                           Text='<%# Eval("AnnouncementMessage") %>' />
                   </td>
                   <td>
                       <asp:Literal ID="projectType" runat="server"
                       Text='<%# Eval("AnnouncementType") %>'>
                       </asp:Literal>
                       <asp:Button ID="Button1" runat="server" Text="Button" />
                   </td>
               </tr>
</ItemTemplate>



My behind file code.
C#
protected void ListView1_DataBound(object sender, EventArgs e)
        {
            foreach (ListViewDataItem item in ListView1.Items)
            {
                Literal project = new Literal();
                Button b = new Button();
                b = (Button)item.FindControl("Button1");
                project =(Literal)item.FindControl("projectType");
                if (project.Text == "Project")
                {
                    b.Text = "This is a project POST";
                }

            }

        }



Any comments or suggestions are kindly appreciated.
AnswerRe: Find asp.net listview control in Item Template Pin
akosidandan15-Aug-11 7:29
akosidandan15-Aug-11 7:29 
QuestionDeserialise complicated Jason data Pin
AndieDu14-Aug-11 15:55
AndieDu14-Aug-11 15:55 
AnswerRe: Deserialise complicated Jason data Pin
BobJanova14-Aug-11 23:18
BobJanova14-Aug-11 23:18 
GeneralRe: Deserialise complicated Jason data Pin
AndieDu15-Aug-11 14:42
AndieDu15-Aug-11 14:42 
AnswerRe: Deserialise complicated Jason data Pin
Bernhard Hiller17-Aug-11 1:00
Bernhard Hiller17-Aug-11 1:00 
QuestionC# MySQL Question Pin
d87c14-Aug-11 13:18
d87c14-Aug-11 13:18 
AnswerRe: C# MySQL Question Pin
Richard Andrew x6414-Aug-11 13:44
professionalRichard Andrew x6414-Aug-11 13:44 
GeneralRe: C# MySQL Question Pin
d87c14-Aug-11 15:33
d87c14-Aug-11 15:33 
GeneralRe: C# MySQL Question Pin
Richard Andrew x6414-Aug-11 15:39
professionalRichard Andrew x6414-Aug-11 15:39 
GeneralRe: C# MySQL Question Pin
d87c14-Aug-11 16:57
d87c14-Aug-11 16:57 
GeneralRe: C# MySQL Question Pin
PIEBALDconsult14-Aug-11 17:59
mvePIEBALDconsult14-Aug-11 17:59 
GeneralMessage Removed Pin
15-Aug-11 2:44
marssilen15-Aug-11 2:44 
GeneralRe: lame-ass hack attempt removed PinPopular
#realJSOP15-Aug-11 2:50
professional#realJSOP15-Aug-11 2:50 
GeneralRe: lame-ass hack attempt removed Pin
OriginalGriff15-Aug-11 3:05
mveOriginalGriff15-Aug-11 3:05 
GeneralRe: lame-ass hack attempt removed Pin
GenJerDan15-Aug-11 5:14
GenJerDan15-Aug-11 5:14 
GeneralRe: C# MySQL Question Pin
BoxyBrown15-Aug-11 22:27
BoxyBrown15-Aug-11 22:27 
AnswerRe: C# MySQL Question Pin
Dave Kreskowiak14-Aug-11 16:57
mveDave Kreskowiak14-Aug-11 16:57 

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.