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

ASP.NET

 
GeneralRe: Dynamically Adding Table Rows Columns in asp.net Pin
N a v a n e e t h22-Jan-08 19:29
N a v a n e e t h22-Jan-08 19:29 
Generalmaster page Pin
RajeevKumarSharma6-Jan-08 19:21
RajeevKumarSharma6-Jan-08 19:21 
GeneralRe: master page Pin
N a v a n e e t h6-Jan-08 20:08
N a v a n e e t h6-Jan-08 20:08 
GeneralRe: master page Pin
RajeevKumarSharma7-Jan-08 0:19
RajeevKumarSharma7-Jan-08 0:19 
Generalaccessing data Pin
nicetohaveyou6-Jan-08 19:02
nicetohaveyou6-Jan-08 19:02 
QuestionCrystal Reports? Pin
Kasi Viswanathan6-Jan-08 18:27
Kasi Viswanathan6-Jan-08 18:27 
GeneralRe: Crystal Reports? Pin
N a v a n e e t h6-Jan-08 20:29
N a v a n e e t h6-Jan-08 20:29 
GeneralThread: Data List delete button problem. [modified] Pin
Albert836-Jan-08 12:16
Albert836-Jan-08 12:16 
Hello,

I am trying to implement the data list delete feature with a linkbutton.

I have different users who login and can view a message posts. I want to give the ability to delete a message only to the one who posted it. So I am trying to loop through the datalist and check if the logged in user has a posted message show the delete link button otherwise don't show the delete button.
I declared a session for the logged in user Session["UserID"] and I am trying to retrieve the userId from the table like this:

<asp:datalist datakeyfield="ChalkboardID" ondeletecommand="DataList1_DeleteCommand" id="DataList1" repeatlayout="table" runat="server" datasourceid="ChalkDL">
<itemtemplate>

<![CDATA[<%
System.Data.DataView dv = ((System.Data.DataView)(ChalkBTable.Select(DataSourceSelectArguments.Empty)));

noMsgLbl.Text = Session["UserID"].ToString();

foreach (System.Data.DataRowView drv in dv)
{
if (drv.Row["UserID"].Equals(Session["UserID"]))
{ %>]]>
<td style="padding-top: 10px;"><asp:linkbutton visible="true" runat="server" commandname="delete" id="deleteBtn" text="Delete"></asp:linkbutton></td>

}
else
{ %&gt;
<td style="padding-top: 10px;"><asp:linkbutton visible="false" runat="server" commandname="delete" id="LinkButton1" text="Delete"></asp:linkbutton></td>
}
}
%&gt;
</itemtemplate></asp:datalist>

It works correct if there is only one post. Meaning the user who posted the message can delete it and others can't because the delete button is not visible.
But once I add another record it gets messed up. Does anybody see the problem or has another solution for this?

Thank you.

<div class="ForumMod">modified on Sunday, January 06, 2008 6:23:08 PM</div>
GeneralRe: Thread: Data List delete button problem. Pin
N a v a n e e t h6-Jan-08 16:33
N a v a n e e t h6-Jan-08 16:33 
GeneralRe: Thread: Data List delete button problem. Pin
Albert836-Jan-08 16:41
Albert836-Jan-08 16:41 
GeneralOne step FileUpload Pin
David Kalkwarf6-Jan-08 5:39
David Kalkwarf6-Jan-08 5:39 
GeneralSystem.Web.HttpUtility.UrlEncode() help help help help Pin
Ahmad Adnan6-Jan-08 3:31
Ahmad Adnan6-Jan-08 3:31 
Generalsave Bitmap ...... Pin
galigal156-Jan-08 3:26
galigal156-Jan-08 3:26 
AnswerRe: save Bitmap ...... Pin
Guffa6-Jan-08 5:20
Guffa6-Jan-08 5:20 
GeneralRe: save Bitmap ...... Pin
galigal156-Jan-08 20:34
galigal156-Jan-08 20:34 
GeneralRe: save Bitmap ...... Pin
Guffa6-Jan-08 20:42
Guffa6-Jan-08 20:42 
GeneralRe: save Bitmap ...... Pin
galigal156-Jan-08 23:08
galigal156-Jan-08 23:08 
GeneralRe: save Bitmap ...... Pin
Guffa7-Jan-08 11:02
Guffa7-Jan-08 11:02 
GeneralRe: save Bitmap ...... Pin
galigal157-Jan-08 19:01
galigal157-Jan-08 19:01 
QuestionStart Windows Service throw web application and Access Denied exception [modified] Pin
mkomasi6-Jan-08 0:48
mkomasi6-Jan-08 0:48 
GeneralDoesnt Fire the Page_load Method Pin
M_Menon5-Jan-08 23:25
M_Menon5-Jan-08 23:25 
GeneralRe: Doesnt Fire the Page_load Method Pin
Christian Graus5-Jan-08 23:53
protectorChristian Graus5-Jan-08 23:53 
GeneralRe: Doesnt Fire the Page_load Method Pin
M_Menon6-Jan-08 1:21
M_Menon6-Jan-08 1:21 
GeneralRe: Doesnt Fire the Page_load Method Pin
N a v a n e e t h6-Jan-08 7:42
N a v a n e e t h6-Jan-08 7:42 
GeneralRe: Doesnt Fire the Page_load Method Pin
M_Menon7-Jan-08 19:35
M_Menon7-Jan-08 19:35 

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.