Can't Get an answer on this one..

CupCakes

New Member
Hi, <BR>It's been a week and I'm coming up empty on this one..<BR>I have an application where users in a call center log their phone calls. This application has search functions where any user can see the calls taken by the entire group. One feature of the search is that in the resulting recordset returned to the user, the calls taken by that user would have a link to edit the entry. I accomplished this in ASP by looping through the recordset, and for each record, I would compare a value in the recordset with a session variable which identified the user as such: <BR><BR><%If Session("UserID") = RS("UserID") Then%><a href=http://aspmessageboard.com/archive/index.php/"edit.asp?record="<%RS("recordID")%><%End If%> <BR><BR>I'm in the process of migrating the app from ASP to ASP.NET and I'm using a SQLDataReader to return the database results. This works great, but how do I evaluate each record to determine if it belongs to the user. I'm assuming I need to compare the Session("User") variable to the <%#Databinder.Eval(Container,"UserID")%> in the ItemTemplate section, but so far I haven't been successful. <BR><BR>Thanks in Advance. <BR><BR>Jon ByrdHi ,<BR>The easiedst way to do it is ( to my opinion) to :<BR>in the HTML page add an extra column to the grid with a link button that you will hide or display based on the fact that the User is the "owner " of the call or not .<BR>Add to the HTML of the grid OnItemCreated="ItemCreated" this will trigger the function ItemCreated() for each row. <BR>in the aspx vb created a function ItemCreated() in which you do your validation . I'll let you search for the visibility of the button...Thanks for the response. I was using a repeater control to display the results as it gave me more artistic control over the results. Do you think that it will be necessary to use a datagrid for this? Thanks again for your prompt response.<BR><BR>JonNo ,<BR>if you used a template for the data repeater you can use the same functionality using , OnItemCreated to add the link button or on the OnItemCommand validate the action to take on the click of the linkbutton.Why wouldn't you just use an sql statement that got only that user's records?<BR><BR>ie. SELECT * FROM table WHERE USERID=@USERID Fill in the @USERID parameter at runtime when you fill the dataset.In this application, each user needs to see the phone calls taken by the entire group, but they can only edit the calls which they originally took. I wish the solution were so simple. It was a simple comparison in ASP.Thanks for the tip, this got me started. Now, how do I access the value of the databinder.eval(container,"dataItem.xxx") from the code behind page? I tried dropping a control into the template such as <asp:textbox id=.. runat=.. text="<%# databinder.eval...%>.<BR>This renders on the page with the correct value, but when I attempt to access this value from the code behind page, it says the object does not exist.<BR>What is the better way to accomplish this?<BR>Thanks.<BR><BR>Jonthe trick here is not to modify the grid but the datasource.<BR>in your textbox tag add OnTextChange="RowChanged"<BR><BR>Protected Sub RowChanged(ByVal sender As Object, ByVal e As System.EventArgs)<BR>Trace.Warn("Entering RowChanged()")<BR>On Error GoTo errHandler<BR>Dim item As DataGridItem = CType(CType(sender, Control).NamingContainer, DataGridItem)<BR> '## Make sure that value entered is valid.<BR> Dim AllocQty As Integer<BR><BR>AllocQty = CInt(CType(item.FindControl("txtQtyReserved"), TextBox).Text)<BR> <BR> ds.Tables(2).Rows(item.ItemIndex).Item("QtyReserved") = AllocQty<BR> ....<BR><BR>When my page will reload , the binding of the control will update the control based on the new information .<BR>don't forget to used the if IsPostback condition to retrieve the modified dataset <BR><BR> If Page.IsPostBack Then<BR> ds = CType(Session("ds"), DataSet)<BR> Else<BR> da.Fill(ds)<BR> Session("ds") = ds<BR> End If<BR> Dt1 = ds.Tables(1)<BR> dlAvailable.DataSource = Dt1<BR><BR> Dt2 = ds.Tables(2)<BR> dgDetail.DataSource = Dt2<BR> DataBind()<BR>sorry this doesn't answer your questio but if you look down the code you see how i did access the data. you can also refer to the e.item.itemIndex to search the datasource for value.
 
Back
Top