Thank you, and because of you i am able to use BYTES.
Yes i am handling ItemCommand event.
Another thing i have to mention is..my appliation is implementation of custom webpart. so there are 2 classes that i am using in my program. 1 is class which implements webpart class and another class is which implements Itemplate for creating custom template.
i am rendering all controls in CreateChildControl( ) method. also i avoided postback problem that will cause problem for dynamic link buttons.
i am placing my logic that i implemented
-
public class RelatedOrganizations : System.Web.UI.WebControls.WebParts.WebPart
-
{
-
//variables
-
DataList dataListTop;
-
DataList dataListBottom;
-
-
//methods
-
protected override void CreateChildControls()
-
{
-
if (!Page.IsPostBack)
-
{
-
-
//adding properties to my datalist
-
dataListBottom = new DataList();
-
dataListBottom.ItemCommand += new DataListCommandEventHandler(dataListBottom_ItemCommand);
-
dataListBottom.SelectedIndexChanged += new EventHandler(dataListBottom_SelectedIndexChanged);
-
TemplateField tfBottom = new TemplateField();
-
tfBottom.ItemTemplate = new GridViewTemplate(DataControlRowType.DataRow, strSalesPositionDescriptionColumn);
-
tfBottom.ItemTemplate = new GridViewTemplate(DataControlRowType.DataRow, strSalesPositionIdColumn);
-
dataListBottom.ItemTemplate = tfBottom.ItemTemplate;
-
-
DataTable dt=getData();
-
dataListBottom.DataSource = dt;
-
dataListBottom.DataBind();
-
-
} //end of if
-
-
}//end of method
-
-
-
//itemcommand event definition
-
void dataListBottom_ItemCommand(object source, DataListCommandEventArgs e)
-
{
-
dataListUpdate(e);
-
}
-
-
}//end of class
-
-
//here is my class for Itemplate with a linkbutton
-
public class GridViewTemplate : ITemplate
-
{
-
private DataControlRowType templateType;
-
private string columnName;
-
-
public GridViewTemplate(DataControlRowType type, string colname)
-
{
-
templateType = type;
-
columnName = colname;
-
}
-
-
public void InstantiateIn(System.Web.UI.Control container)
-
{
-
// Create the content for the different row types.
-
switch (templateType)
-
{
-
case DataControlRowType.Header:
-
-
break;
-
case DataControlRowType.DataRow:
-
LinkButton lnkbSPDesc = new LinkButton();
-
lnkbSPDesc.DataBinding += new EventHandler(lnkbSPDesc_DataBinding);
-
lnkbSPDesc.Click += new EventHandler(lnkbSPDesc_Click);
-
container.Controls.Add(lnkbSPDesc);
-
break;
-
-
-
default:
-
break;
-
}
-
}
-
-
void lnkbSPDesc_Click(object sender, EventArgs e)
-
{
-
LinkButton lb = (LinkButton)sender;
-
-
}
-
-
void lnkbSPDesc_DataBinding(object sender, EventArgs e)
-
{
-
-
LinkButton l = (LinkButton)sender;
-
//Label l = (Label)sender;
-
-
DataListItem item = (DataListItem)l.NamingContainer;
-
-
-
POAICSharepointUtility.GetConfigKey("");
-
l.Text = DataBinder.Eval(item.DataItem, POAICSharepointUtility.GetConfigKey("SalesPositionDescriptionColumn")).ToString();
-
l.CommandArgument = DataBinder.Eval(item.DataItem, POAICSharepointUtility.GetConfigKey("SalesPositionIdColumn")).ToString();
-
l.CommandName = DataBinder.Eval(item.DataItem, POAICSharepointUtility.GetConfigKey("SalesPositionIdColumn")).ToString();
-
l.Click += new EventHandler(l_Click);
-
} //end of class
I hope this code will help you for understanding my problem.
looking for your reply.
thank you