usercontrol code ::
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WhyJoined.ascx.cs" Inherits="CommunityServerWeb.Themes._default.User.WhyJoined" %><%@ Import Namespace="CommunityServer.Components" %><%@ Import Namespace="CommunityServer.Controls" %><asp:UpdatePanel runat="server" ID="joinpanel" ChildrenAsTriggers="true" UpdateMode="Always"><Triggers> <asp:AsyncPostBackTrigger ControlID="dgwhyjoined" EventName="UpdateCommand" /> <asp:AsyncPostBackTrigger ControlID="dgwhyjoined" EventName="EditCommand" /> <asp:AsyncPostBackTrigger ControlID="dgwhyjoined" EventName="CancelCommand" /></Triggers><ContentTemplate><asp:DataGrid ID="dgwhyjoined" runat="server" oncancelcommand="dgwhyjoined_CancelCommand" oneditcommand="dgwhyjoined_EditCommand" onupdatecommand="dgwhyjoined_UpdateCommand" AutoGenerateColumns="false" > <Columns> <asp:TemplateColumn> <ItemTemplate> <asp:Label ID="lblmsg" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"WhyJoined") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtmsg" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"WhyJoined") %>'></asp:TextBox> </EditItemTemplate> </asp:TemplateColumn> <asp:EditCommandColumn CancelText="Cancel" UpdateText="Update" EditText="Edit"></asp:EditCommandColumn> </Columns> </asp:DataGrid></ContentTemplate></asp:UpdatePanel>
codebehind file
using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using CommunityServer.Controls;using CommunityServer;using CommunityServer.Components;using System.Collections.Generic;using System.IO;using System.Xml;using CommunityServer.Discussions.Components;using CommunityServer.Files.Components;
namespace CommunityServerWeb.Themes._default.User{ public partial class WhyJoined : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { binddata(); } private void binddata() { DataTable table = new DataTable(); table.Columns.Add("WhyJoined"); table.Rows.InsertAt(table.NewRow(), 0); table.Rows[0]["WhyJoined"] = CSControlUtility.Instance().GetCurrentUser(this).GetExtendedAttribute("WhyJoined").ToString(); dgwhyjoined.DataSource = table; dgwhyjoined.DataBind(); }
protected void dgwhyjoined_CancelCommand(object source, DataGridCommandEventArgs e) { dgwhyjoined.EditItemIndex = -1; binddata(); }
protected void dgwhyjoined_EditCommand(object source, DataGridCommandEventArgs e) { dgwhyjoined.EditItemIndex = e.Item.ItemIndex; binddata(); }
protected void dgwhyjoined_UpdateCommand(object source, DataGridCommandEventArgs e) { TextBox txtwhyjoined = new TextBox(); txtwhyjoined = (TextBox)e.Item.FindControl("txtmsg"); CSControlUtility.Instance().GetCurrentUser(this).SetExtendedAttribute("WhyJoined", txtwhyjoined.Text.ToString()); dgwhyjoined.EditItemIndex = -1; binddata(); } }}
I have managed to get a grid inside a update panel(without full page post back) where i am able to get update and cancel buttons on clicking edit button.but when i click on update the event i snot gettting fired ..what might be the problem.???
??
AnyBody There??
Sorry, that's a query about ASP.Net as opposed to Community Server. Whilst someone may be able to answer your question, you'll probably have more luck posting it at http://forums.asp.net instead. From my experience, I've found that firing events inside Grid Views always causes some form of problem.
Anyway, I'm not sure why you're using a DataGrid, especially since you know you're only going to have one row? It'll be much simpler, and less overhead to say have two panels - one with just a label and an "edit" button, the second with a textbox, and update and an cancel button (actually, I'll disagree with the existance of the first panel but that's the functionality you seem to want to get by using the grid view). The first panel only will need to contain <CSControl:UserData runat="server" ExtendedAttribute="WhyJoined" UseAccessingUser="true" /> and the edit button. The Edit button would then hide the first panel, and make the second visible. The textbox would display the extended attribute value, the update would save it, and the cancel button would hide that panel and make the first visible again.
Community Server Documentation
Nintendo Wiikly
This sounds good.I have used panels.its working now.Thanks!
One more problem.
the extended attribute is not being saved.what could be the problem.??
I am setting the extended attribute using CSControlUtility.Instance().GetCurrentUser(this).SetExtendedAttribute("WhyJoined", txtwhyjoined.Text.ToString());.
Is that sufficient or anything else???
You're setting the extended attribute correctly, but you need to save that change, for which you'll need to use Users.Update()
p.s. Try to avoid bumping threads with ???, particularly after only 2 Hours! as it only serves to irritate people, making them less likely to answer your questions. The same goes for posting the same problem multiple times in different forums. By all means add any extra information that may be of help in solving the problem. If you want quicker, and guaranteed answers to your questions, then you should look at purchasing Gold Support, for which you'll have to email sales@telligent.com for further information.
Copyright© 2008 Telligent Systems Inc. All rights reserved CommunityServer.com • Telligent.com