How to do this??

S

smita

Hi,

I want to display a list usernames and along with each username I want
to display an Edit link and Delete link on my web page.This needs to be done
dynamically as the list of users will keep increasing as new users register.

Now, the problem is that i am not using any Database,but instead i m
using an Xml file for storing these usernames. I can retrieve the list of
users from the xml file but am not able to display them along with the links
such that the click of the Edit link should take me to the Edit web page
containing the corresponding users details(which ofcourse I'll need to
display based on which users Edit link has been clicked.)

Can you please tell me which is the best way to implement this?

I have tried using a Datagrid but i m only able to display the list of
usernames and not the links.

Thanks in advance:)
Smita.
 
S

Scot Meyer

Well if you already have the DataGrid implemented then it wouldn't be a big step to add a custom column for your Add and Delete links. See the code below

In your html Datagrid ad
<columns
...
<org:LinkColumn HeaderText="ADD" IsHyperlink="true" ItemStyle-Width="64" DataField="CustomerName"><ItemStyle Font-Size="8pt" HorizontalAlign=left /></org:LinkColumn>
...
</columns

sing System.Web.UI
using System.Web.UI.WebControls
using System.ComponentModel
using System.Data
using System.Web
namespace or

/// <summary
/// Summary description for WebCustomControl1
/// </summary
[DefaultProperty("Text")
ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")

public class LinkColumn : System.Web.UI.WebControls.DataGridColum

private string text
private string dataField
private bool isHyperlink
static System.Web.HttpServerUtility Server= HttpContext.Current.Server

[Bindable(true)
Category("Appearance")
DefaultValue("")
public string Tex

get {return text;
set {text = value;


[Bindable(true)
Category("Appearance")
DefaultValue("")
public bool IsHyperlin

get {return isHyperlink;
set {isHyperlink = value;


[Bindable(true)
Category("Data")
DefaultValue("")
public string DataFiel

get { return dataField;
set { dataField=value;

public override void InitializeCell(TableCell cell,int ColumnIndex, ListItemType itemType)

base.InitializeCell(cell,ColumnIndex,itemType)
switch (itemType)

case ListItemType.Header
//cell.Text = HeaderText
break
case ListItemType.Item
case ListItemType.AlternatingItem
cell.DataBinding += new EventHandler(this.ItemDataBinding)
break
case ListItemType.EditItem
break




private void ItemDataBinding(Object sender, EventArgs e

TableCell cell = (TableCell)sender
DataGridItem DGI= (DataGridItem)cell.NamingContainer
String strReturnText=""

try

try

// Returns 2
string Text = ((DataRowView)DGI.DataItem)[this.DataField].ToString()

if (IsHyperlink)

strReturnText = @"<u><font color=""blue"" style=""cursor:hand; FONT-SIZE:8pt"" onclick=""Add('"
strReturnText += ((DataRowView)DGI.DataItem)["RecordID"].ToString()
strReturnText += @"');"""
strReturnText += @"language='javascript' >" + Text + "</font></u>"

els
strReturnText = @"<font style=""FONT-SIZE:8pt"">" + Text + "</font>"

catch (Exception ex)
strReturnText = ((DataRowView)DGI.DataItem)[this.DataField].ToString() + "nbsp;"


cell.Text = strReturnText
}
catch (IndexOutOfRangeException RangeEx)

throw new Exception("Specified DataField was not found.")

catch (Exception ex)

throw new Exception(ex.Message.ToString())
}




:please keep the responses in the thread as this will help others that may have similar problem
I make no warranties on the code (if any) listed her
mailmeat: scotchy32000 at yahoo nospam dot com <- remove nospam add @ .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top