Hello, I have application like wall facebook the user can add something on wall and the other user can comment on it.
I have done this by using DataList please review below print screen for my page translated to english.
my problem i want when user click on the button in DataList save this data in database.
Topic ID , Topic Subject.
How i can separation between Topic ID label in data list?
I using default code but naturally i get error the lblID.Text is not exist
Insert Code:
Code:cmd = new SqlCommand("Insert into [tbWallComments] (PostID) values (N'"+lblID.Text+"')", cnn); cnn.Open(); cmd.ExecuteScalar(); cnn.Close();
Print Screen:
Uploaded with ImageShack.us
DataListCode:
Code:<asp:DataList ID="DataList1" runat="server" DataKeyField="ID" DataSourceID="DSStudentWall" onselectedindexchanged="DataList1_SelectedIndexChanged"> <ItemTemplate> <table border="1" width="800px" dir="rtl" align="right"> <tr> <td align="center" rowspan="4"> <asp:Image ID="Image2" runat="server" ImageUrl="Images/defaultprofile.gif" /> </td> <td align="right"> <asp:Label ID="PublishNameLabel" runat="server" Font-Bold="True" Text="publisher:" Visible="False" /> <%# Eval("PublishName") %> </td> </tr> <tr> <td align="right"> <asp:Label ID="SubjectLabel" runat="server" Font-Bold="True" Text="Subject:" Visible="False" /> <%# Eval("Subject") %> </td> </tr> <tr> <td align="right"> <asp:Label ID="BodyLabel" runat="server" Font-Bold="True" Text="Topic:" Visible="False" /> <%# Eval("Body") %> </td> </tr> <tr> <td align="left" width="680"> <asp:Label ID="PublishDateLabel" runat="server" Font-Bold="true" Text="Date:" /> <%# Eval("PublishDate") %> <asp:Label ID="PublishTimeLabel" runat="server" Font-Bold="true" Text="Time" /> <%# Eval("PublishTime") %> <asp:Label ID="lblID" runat="server" Font-Bold="true" Text='<%# Eval("ID") %>' /> </td> </tr> <tr> <td align="left" colspan="2"> <table align="center" bgcolor="#EDEBEB" dir="ltr" width="100%"> <tr> <td align="right"> </td> <td align="left" class="style3"> </td> </tr> <tr> <td align="right"> <asp:Button ID="BtSaveComment" runat="server" CssClass="groovybutton" Font-Bold="True" Font-Size="Medium" onclick="BtSaveComment_Click" Text="AddComment" Width="109px"/> <asp:TextBox ID="txtBody" runat="server" Height="50px" MaxLength="1000" TextMode="MultiLine" Width="288px"></asp:TextBox> </td> <td align="left" class="style3"> <asp:Label ID="Label8" runat="server" Font-Bold="True" Font-Size="Medium" Text=":Comment"></asp:Label> </td> </tr> </table> </td> </tr> </table> </ItemTemplate> </asp:DataList>





Reply With Quote